|
|
|
|
use QingDao_saidao16
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
select * from TEmployeeReferral
|
|
|
|
|
|
|
|
|
|
UPDATE TEmployeeReferral SET FCompId = 0
|
|
|
|
|
|
|
|
|
|
EXEC PChangeCenterCompany '003'
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TMemberCardTypeAccount
|
|
|
|
|
|
|
|
|
|
DELETE TMemberCardTypeAccount WHERE FCompId = 4877384222910420443
|
|
|
|
|
|
|
|
|
|
--ɾ<EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD>
|
|
|
|
|
SELECT * FROM DongYing_DongHua..TCompany
|
|
|
|
|
SELECT * FROM DongYing_DongHua_LiCangWanDa..TCompany
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE DongYing_DongHua.dbo.TCompany SET FDeleted = 1,FNo = FNo + '<EFBFBD><EFBFBD>ɾ' WHERE FNo IN('006')
|
|
|
|
|
UPDATE DongYing_DongHua_LiCangWanDa.dbo.TCompany SET FDeleted = 1,FNo = FNo + '<EFBFBD><EFBFBD>ɾ' WHERE FNO NOT IN('','006')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
update TCompany SET FDeleted = 1 WHERE FId = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TMemberCard WHERE FCompId != 4877384222910420443
|
|
|
|
|
AND FCardId IN(SELECT FCardId FROM TConsumeBill WHERE FCompId = 4877384222910420443)
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>
|
|
|
|
|
UPDATE DongYing_DongHua.dbo.TMemberCard SET FDeleted = 1,FCardNo = FCardNo + '<EFBFBD><EFBFBD>ɾ',FMemo = FMemo + '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
WHERE FDeleted= 0
|
|
|
|
|
AND FCompId = 4877384222910420443
|
|
|
|
|
|
|
|
|
|
UPDATE DongYing_DongHua_LiCangWanDa.dbo.TMemberCard SET FDeleted = 1,FCardNo = FCardNo + '<EFBFBD><EFBFBD>ɾ',FMemo = FMemo + '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
WHERE FDeleted= 0
|
|
|
|
|
AND FCompId != 4877384222910420443
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE DongYing_DongHua..TMemberCourse SET FDeleted = 1, FMemo = FMemo + '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
WHERE FDeleted= 0
|
|
|
|
|
AND FCompId = 4877384222910420443
|
|
|
|
|
|
|
|
|
|
UPDATE DongYing_DongHua_LiCangWanDa..TMemberCourse SET FDeleted = 1, FMemo = FMemo + '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
WHERE FDeleted= 0
|
|
|
|
|
AND FCompId != 4877384222910420443
|
|
|
|
|
|
|
|
|
|
UPDATE DongYing_DongHua..TMember SET FDeleted = 0,FMemNo = REPLACE(FMemNo, '<EFBFBD><EFBFBD>ɾ',''),FMemo = REPLACE(FMemo , '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','')
|
|
|
|
|
WHERE FMemo LIKE '%<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%'
|
|
|
|
|
AND FDeleted = 1
|
|
|
|
|
|
|
|
|
|
UPDATE DongYing_DongHua_licangwanda..TMember SET FDeleted = 0,FMemNo = REPLACE(FMemNo, '<EFBFBD><EFBFBD>ɾ',''),FMemo = REPLACE(FMemo , '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>','')
|
|
|
|
|
WHERE FMemo LIKE '%<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%'
|
|
|
|
|
AND FDeleted = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE DongYing_DongHua..TMember SET FDeleted = 1,FMemNo = FMemNo + '<EFBFBD><EFBFBD>ɾ',FMemo = FMemo + '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
WHERE FDeleted= 0
|
|
|
|
|
AND FCompId = 4877384222910420443
|
|
|
|
|
AND FMemId NOT IN(SELECT FMemId FROM DongYing_DongHua..TMemberCard WHERE FDeleted = 0)
|
|
|
|
|
AND FMemId NOT IN(SELECT FMemId FROM DongYing_DongHua..TMemberCourse WHERE FDeleted = 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE DongYing_DongHua SET FMemId = (SELECT FMemId FROM TMemberCard )
|
|
|
|
|
|
|
|
|
|
UPDATE DongYing_DongHua_LiCangWanDa..TMember SET FDeleted = 1,FMemNo = FMemNo + '<EFBFBD><EFBFBD>ɾ',FMemo = FMemo + '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
|
|
|
|
|
WHERE FDeleted= 0
|
|
|
|
|
AND FCompId != 4877384222910420443
|
|
|
|
|
AND FMemId NOT IN(SELECT FMemId FROM DongYing_DongHua_LiCangWanDa..TMemberCard WHERE FDeleted = 0)
|
|
|
|
|
AND FMemId NOT IN(SELECT FMemId FROM DongYing_DongHua_LiCangWanDa..TMemberCourse WHERE FDeleted = 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
DELETE DongYing_DongHua..TEmployeeSub WHERE FCompId = 4877384222910420443
|
|
|
|
|
DELETE DongYing_DongHua..TItemSub WHERE FCompId = 4877384222910420443
|
|
|
|
|
DELETE DongYing_DongHua..TGoodsSub WHERE FCompId = 4877384222910420443
|
|
|
|
|
DELETE DongYing_DongHua..TBasicTypeSub WHERE FCompId = 4877384222910420443
|
|
|
|
|
|
|
|
|
|
DELETE DongYing_DongHua_LiCangWanDa..TEmployeeSub WHERE FCompId != 4877384222910420443
|
|
|
|
|
DELETE DongYing_DongHua_LiCangWanDa..TItemSub WHERE FCompId != 4877384222910420443
|
|
|
|
|
DELETE DongYing_DongHua_LiCangWanDa..TGoodsSub WHERE FCompId != 4877384222910420443
|
|
|
|
|
DELETE DongYing_DongHua_LiCangWanDa..TBasicTypeSub WHERE FCompId != 4877384222910420443
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DROP TABLE #ConsumeBill
|
|
|
|
|
|
|
|
|
|
DROP TABLE #MemberSaleBill
|
|
|
|
|
|
|
|
|
|
-- SELECT FBillId INTO #ConsumeBill FROM TConsumeBill
|
|
|
|
|
-- WHERE FCompId = 8308717354799492172
|
|
|
|
|
-- AND FMemId NOT IN(SELECT FMemId FROM TMember WHERE FDeleted = 0)
|
|
|
|
|
|
|
|
|
|
-- SELECT FBillId INTO #MemberSaleBill FROM TMemberSaleBill
|
|
|
|
|
-- WHERE FCompId = 8308717354799492172
|
|
|
|
|
-- AND FMemId NOT IN(SELECT FMemId FROM TMember WHERE FDeleted = 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT 'DELETE ' + NAME + ' WHERE FBillId IN(SELECT FBillId FROM #ConsumeBill)' FROM sysobjects WHERE name like 'TConsume%'
|
|
|
|
|
SELECT 'DELETE ' + NAME + ' WHERE FBillId IN(SELECT FBillId FROM #MemberSaleBill)' FROM sysobjects WHERE name like 'TMemberSale%'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DELETE TConsumeItemCostGoods WHERE FBillId IN(SELECT FBillId FROM #ConsumeBill)
|
|
|
|
|
DELETE TConsumeItemEmployee WHERE FBillId IN(SELECT FBillId FROM #ConsumeBill)
|
|
|
|
|
DELETE TConsumeItemPayment WHERE FBillId IN(SELECT FBillId FROM #ConsumeBill)
|
|
|
|
|
DELETE TConsumeReturnVisit WHERE FBillId IN(SELECT FBillId FROM #ConsumeBill)
|
|
|
|
|
DELETE TConsumeReturnVisitLog WHERE FBillId IN(SELECT FBillId FROM #ConsumeBill)
|
|
|
|
|
DELETE TConsumeBill WHERE FBillId IN(SELECT FBillId FROM #ConsumeBill)
|
|
|
|
|
DELETE TConsumeGoods WHERE FBillId IN(SELECT FBillId FROM #ConsumeBill)
|
|
|
|
|
DELETE TConsumeGoodsEmployee WHERE FBillId IN(SELECT FBillId FROM #ConsumeBill)
|
|
|
|
|
DELETE TConsumeGoodsPayment WHERE FBillId IN(SELECT FBillId FROM #ConsumeBill)
|
|
|
|
|
DELETE TConsumeItem WHERE FBillId IN(SELECT FBillId FROM #ConsumeBill)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DELETE TMemberSalePayment WHERE FBillId IN(SELECT FBillId FROM #MemberSaleBill)
|
|
|
|
|
DELETE TMemberSaleRepay WHERE FBillId IN(SELECT FBillId FROM #MemberSaleBill)
|
|
|
|
|
DELETE TMemberSaleBill WHERE FBillId IN(SELECT FBillId FROM #MemberSaleBill)
|
|
|
|
|
DELETE TMemberSaleCard WHERE FBillId IN(SELECT FBillId FROM #MemberSaleBill)
|
|
|
|
|
DELETE TMemberSaleCombo WHERE FBillId IN(SELECT FBillId FROM #MemberSaleBill)
|
|
|
|
|
DELETE TMemberSaleCourse WHERE FBillId IN(SELECT FBillId FROM #MemberSaleBill)
|
|
|
|
|
DELETE TMemberSaleCourseGoods WHERE FBillId IN(SELECT FBillId FROM #MemberSaleBill)
|
|
|
|
|
DELETE TMemberSaleCoursePack WHERE FBillId IN(SELECT FBillId FROM #MemberSaleBill)
|
|
|
|
|
DELETE TMemberSaleDetailPayment WHERE FBillId IN(SELECT FBillId FROM #MemberSaleBill)
|
|
|
|
|
DELETE TMemberSaleEmployee WHERE FBillId IN(SELECT FBillId FROM #MemberSaleBill)
|
|
|
|
|
DELETE TMemberSaleExchange WHERE FBillId IN(SELECT FBillId FROM #MemberSaleBill)
|
|
|
|
|
DELETE TMemberSaleExchangeSource WHERE FBillId IN(SELECT FBillId FROM #MemberSaleBill)
|
|
|
|
|
DELETE TMemberSaleFreeItem WHERE FBillId IN(SELECT FBillId FROM #MemberSaleBill)
|
|
|
|
|
DELETE TMemberSaleInfo WHERE FBillId IN(SELECT FBillId FROM #MemberSaleBill)
|
|
|
|
|
DELETE TMemberSaleDetailSplit WHERE FBillId IN(SELECT FBillId FROM #MemberSaleBill)
|
|
|
|
|
|
|
|
|
|
DELETE TItemSub WHERE FCompId NOT IN(SELECT FId FROM TCompany WHERE FDeleted =0 )
|
|
|
|
|
DELETE TGoodsSub WHERE FCompId NOT IN(SELECT FId FROM TCompany WHERE FDeleted =0 )
|
|
|
|
|
DELETE TBasicTypeSub WHERE FCompId NOT IN(SELECT FId FROM TCompany WHERE FDeleted =0 )
|
|
|
|
|
DELETE TMemberCardTypeSub WHERE FCompId NOT IN(SELECT FId FROM TCompany WHERE FDeleted =0 )
|
|
|
|
|
DELETE TEmployeeSub WHERE FCompId NOT IN(SELECT FId FROM TCompany WHERE FDeleted =0 )
|
|
|
|
|
|
|
|
|
|
DELETE TEmployee WHERE FId NOT IN(SELECT FEmpId FROM TEmployeeSub )
|
|
|
|
|
AND FId > 1
|
|
|
|
|
AND FId NOT IN(SELECT FEmpId FROM TConsumeItemEmployee UNION ALL SELECT FEmpId FROM TCOnsumeGoodsEmployee UNION ALL SELECT FEmpId FROM TMemberSaleEmployee)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>γ<EFBFBD>ֵ<EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD>
|
|
|
|
|
|
|
|
|
|
DROP TABLE #Card
|
|
|
|
|
|
|
|
|
|
CREATE TABLE #Card
|
|
|
|
|
(
|
|
|
|
|
FCardId BIGINT,
|
|
|
|
|
FCompId BIGINT,
|
|
|
|
|
FNewCompId BIGINT
|
|
|
|
|
)
|
|
|
|
|
INSERT #Card(FCardId,FCompId)
|
|
|
|
|
SELECT A.FCardId,C.FCompId FROM TMemberSaleCard AS A,TMemberSaleBill AS B,TMemberCard AS C
|
|
|
|
|
WHERE A.FBillId = B.FBilliD
|
|
|
|
|
AND C.FCardId = A.FCardId
|
|
|
|
|
AND B.FState = 1
|
|
|
|
|
AND B.FBizType = 'CardRchg'
|
|
|
|
|
AND A.FSalePrice > 0
|
|
|
|
|
GROUP BY A.FCardId,C.FCompId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DECLARE @CardId BIGINT
|
|
|
|
|
DECLARE @CardNo VARCHAR(300)
|
|
|
|
|
DECLARE @CompId BIGINT
|
|
|
|
|
DECLARE @OwnerCompId BIGINT
|
|
|
|
|
|
|
|
|
|
DECLARE List CURSOR FOR SELECT FCardId,FCompId FROM #Card
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OPEN List
|
|
|
|
|
FETCH List INTO @CardId,@OwnerCompId
|
|
|
|
|
|
|
|
|
|
WHILE @@FETCH_STATUS = 0
|
|
|
|
|
BEGIN
|
|
|
|
|
DECLARE @EmpId BIGINT
|
|
|
|
|
|
|
|
|
|
SELECT TOP 1 @CompId = T.FCompId
|
|
|
|
|
FROM TMemberSaleCard AS B,TMemberSaleBill AS T
|
|
|
|
|
WHERE T.FBillId = B.FBillId
|
|
|
|
|
AND B.FSalePrice > 0
|
|
|
|
|
AND B.FCardId = @CardId
|
|
|
|
|
ORDER BY T.FBillTime DESC
|
|
|
|
|
|
|
|
|
|
DECLARE @NewCompId BIGINT
|
|
|
|
|
SELECT @NewCompId = 0
|
|
|
|
|
|
|
|
|
|
IF @OwnerCompId = 4877384222910420443 AND @CompId != 4877384222910420443
|
|
|
|
|
BEGIN
|
|
|
|
|
SELECT @NewCompId = @CompId
|
|
|
|
|
END
|
|
|
|
|
IF @OwnerCompId != 4877384222910420443 AND @CompId = 4877384222910420443
|
|
|
|
|
BEGIN
|
|
|
|
|
SELECT @NewCompId = @CompId
|
|
|
|
|
END
|
|
|
|
|
|
|
|
|
|
IF @NewCompId != 0
|
|
|
|
|
BEGIN
|
|
|
|
|
PRINT @NewCompId
|
|
|
|
|
UPDATE #Card SET FNewCompId = @NewCompId WHERE FCardId = @CardId
|
|
|
|
|
END
|
|
|
|
|
|
|
|
|
|
FETCH List INTO @CardId,@OwnerCompId
|
|
|
|
|
END
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CLOSE List
|
|
|
|
|
DEALLOCATE LIST
|
|
|
|
|
|
|
|
|
|
SELECT * FROM TMemberCard
|
|
|
|
|
WHERE FCardId IN(
|
|
|
|
|
SELECT FCardId FROM #Card WHERE ISNULL(FNewCompId,0) != 0
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
-- UPDATE A
|
|
|
|
|
-- SET A.FCompId = B.FNewCompId
|
|
|
|
|
-- FROM #Card AS B,DongYing_DongHua..TMemberCard AS A
|
|
|
|
|
-- WHERE A.FCardId = B.FCardId
|
|
|
|
|
-- AND A.FCompId != B.FNewCompId
|
|
|
|
|
|
|
|
|
|
UPDATE DongYing_DongHua..TMemberCard SET FDeleted = 0,FCardNO = REPLACE(FCardNo,'<EFBFBD><EFBFBD>ɾ' ,''),FMemo = REPLACE(FMemo,'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','')
|
|
|
|
|
WHERE FCardId IN(SELECT FCardId FROM #Card)
|
|
|
|
|
|
|
|
|
|
UPDATE DongYing_DongHua..TMemberCard
|
|
|
|
|
SET FDeleted = 0,
|
|
|
|
|
FCardNO = REPLACE(FCardNo,'<EFBFBD><EFBFBD>ɾ' ,''),
|
|
|
|
|
FMemo = REPLACE(FMemo,'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>','')
|
|
|
|
|
WHERE FCardId IN(SELECT FCardId FROM #Card )
|
|
|
|
|
AND FDeleted = 1
|
|
|
|
|
AND FMemo LIKE '%<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE DongYing_DongHua..TMemberCard
|
|
|
|
|
SET FDeleted = 0,
|
|
|
|
|
FCardNO = REPLACE(FCardNo,'<EFBFBD><EFBFBD>ɾ' ,''),
|
|
|
|
|
FMemo = REPLACE(FMemo,'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','')
|
|
|
|
|
WHERE 1=1
|
|
|
|
|
--WHERE FCardId IN(SELECT FCardId FROM #Card AND ISNULL(FNewCompId,0) != 0 )
|
|
|
|
|
AND FDeleted = 1
|
|
|
|
|
AND FMemo LIKE '%<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCompId = B.FCompId
|
|
|
|
|
FROM DongYing_DongHua..TMemberCard AS B,DongYing_DongHua..TMember AS A
|
|
|
|
|
WHERE A.FMemId = B.FMemId
|
|
|
|
|
AND A.FCompId != B.FCompId
|
|
|
|
|
AND b.FCardId IN(SELECT FCardId FROM #Card WHERE ISNULL(FNewCompId,0) != 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UPDATE A
|
|
|
|
|
SET A.FCompId = B.FCompId
|
|
|
|
|
FROM DongYing_DongHua_LICANGWANDA..TMemberCard AS B,DongYing_DongHua_LICANGWANDA..TMember AS A
|
|
|
|
|
WHERE A.FMemId = B.FMemId
|
|
|
|
|
AND A.FCompId != B.FCompId
|
|
|
|
|
AND b.FCardId IN(SELECT FCardId FROM #Card WHERE ISNULL(FNewCompId,0) != 0)
|
|
|
|
|
|
|
|
|
|
|