

SELECT * FROM TMemberSaleDetailPayment 
SELECT * FROM TMemberSalePayment 

select * from TConsumeBill WHERE FCompId = 

SELECT * FROM TCompany 

SELECT * FROM TUserAllowCompany 

DELETE TBasicDataChanges
DELETE TBasicTypeSub WHERE  FCompId != 3472609564237496320
DELETE TUserAllowCompany WHERE FCompId != 3472609564237496320
DELETE TBizLog WHERE  FCompId != 3472609564237496320
DELETE TPayAccountSub WHERE  FCompId != 3472609564237496320
DELETE TBasicTypeSub WHERE  FCompId != 3472609564237496320
DELETE TItemSub WHERE  FCompId != 3472609564237496320
DELETE TReportParam WHERE  FCompId != 3472609564237496320
SELECT * FROM TItemSub 

DELETE TCompany WHERE FId != 3472609564237496320 AND FId != 1 


DELETE B FROM TConsumeBill AS A,TConsumeItemEmployee AS B WHERE B.FBillId = A.FBillId AND FCompId != 3472609564237496320
DELETE B FROM TConsumeBill AS A,TConsumeItemPayment AS B WHERE B.FBillId = A.FBillId AND FCompId != 3472609564237496320
DELETE B FROM TConsumeBill AS A,TConsumeItem AS B WHERE B.FBillId = A.FBillId AND FCompId != 3472609564237496320

DELETE B FROM TConsumeBill AS A,TConsumeGoodsEmployee AS B WHERE B.FBillId = A.FBillId AND FCompId != 3472609564237496320
DELETE B FROM TConsumeBill AS A,TConsumeGoodsPayment AS B WHERE B.FBillId = A.FBillId AND FCompId != 3472609564237496320
DELETE B FROM TConsumeBill AS A,TConsumeGoods AS B WHERE B.FBillId = A.FBillId AND FCompId != 3472609564237496320

DELETE TConsumeBill WHERE  FCompId != 3472609564237496320

DELETE B FROM TMemberSalePayment AS B, TMemberSaleBill AS A WHERE A.FBillId = B.FBillId AND FCompId != 3472609564237496320
DELETE B FROM TMemberSaleCard AS B, TMemberSaleBill AS A WHERE A.FBillId = B.FBillId AND FCompId != 3472609564237496320
DELETE B FROM TMemberSaleEmployee AS B, TMemberSaleBill AS A WHERE A.FBillId = B.FBillId AND FCompId != 3472609564237496320
DELETE B FROM TMemberSaleRepay AS B, TMemberSaleBill AS A WHERE A.FBillId = B.FBillId AND FCompId != 3472609564237496320
DELETE B FROM TMemberSaleCourse AS B, TMemberSaleBill AS A WHERE A.FBillId = B.FBillId AND FCompId != 3472609564237496320
DELETE B FROM TMemberSaleCoursePack AS B, TMemberSaleBill AS A WHERE A.FBillId = B.FBillId AND FCompId != 3472609564237496320
DELETE B FROM TMemberSaleCourseGoods AS B, TMemberSaleBill AS A WHERE A.FBillId = B.FBillId AND FCompId != 3472609564237496320
DELETE B FROM TMemberSaleDetailPayment AS B, TMemberSaleBill AS A WHERE A.FBillId = B.FBillId AND FCompId != 3472609564237496320
DELETE B FROM TMemberSaleExchange AS B, TMemberSaleBill AS A WHERE A.FBillId = B.FBillId AND FCompId != 3472609564237496320
DELETE B FROM TMemberSaleExchangeSource AS B, TMemberSaleBill AS A WHERE A.FBillId = B.FBillId AND FCompId != 3472609564237496320
DELETE B FROM TMemberSaleExchangeTarget AS B, TMemberSaleBill AS A WHERE A.FBillId = B.FBillId AND FCompId != 3472609564237496320
DELETE B FROM TMemberSaleFreeItem AS B, TMemberSaleBill AS A WHERE A.FBillId = B.FBillId AND FCompId != 3472609564237496320
DELETE B FROM TMemberSaleInfo AS B, TMemberSaleBill AS A WHERE A.FBillId = B.FBillId AND FCompId != 3472609564237496320
DELETE B FROM TMemberSaleBill AS B WHERE FCompId != 3472609564237496320




SELECT * FROM TCompany WHERE FId = 3472609564237496320

SELECT * FROM TConsumeBill WHERE FCompId != 3472609564237496320
SELECT * FROM TMemberSaleBill WHERE FCompId != 3472609564237496320


DELETE TMember
SELECT * FROM TMember

DELETE D 
FROM TMemberTransHistPayment AS D,TMember AS A
WHERE D.FMemId = A.FId
AND A.FCompId != 3472609564237496320

DELETE D 
FROM TMemberTransHist AS D,TMember AS A
WHERE D.FMemId = A.FId
AND A.FCompId != 3472609564237496320


DELETE D 
FROM TMemberCardAcctHist AS D,TMember AS A
WHERE D.FMemId = A.FId
AND A.FCompId != 3472609564237496320

DELETE D 
FROM TMemberRepay AS D,TMember AS A
WHERE D.FMemId = A.FId
AND A.FCompId != 3472609564237496320


DELETE D 
FROM TMemberArrearEmployee AS D,TMember AS A
WHERE D.FMemId = A.FId
AND A.FCompId != 3472609564237496320

DELETE D 
FROM TMemberArrear AS D,TMember AS A
WHERE D.FMemId = A.FId
AND A.FCompId != 3472609564237496320

DELETE D 
FROM TMemberCardAccount AS D,TMemberCard AS A
WHERE D.FCardId = A.FId
AND A.FCompId != 3472609564237496320

DELETE D 
FROM TMemberCard AS D
WHERE D.FCompId != 3472609564237496320

DELETE D 
FROM TMember AS D
WHERE D.FCompId != 3472609564237496320



INSERT INTO TMemberCard(FId,FNo,FFaceNo,FTypeId,FValueType,FCompId,FMemId,FState,FCreateDate,FExpiredDate,FTotalTimes,FUsedTimes,FPoint,FSaleCompId,FSaleBillId,FMemo)
    SELECT FId,FNo,FFaceNo,FTypeId,FValueType,FCompId,FMemId,FState,FCreateDate,FExpiredDate,FTotalTimes,FUsedTimes,FPoint,FSaleCompId,FSaleBillId,FMemo FROM Nskdrf_bak..TMemberCard
 WHERE FCompId = 3472609564237496320

INSERT TMemberCardAccount
SELECT A.* FROM Nskdrf_bak..TMemberCardAccount AS A,TMemberCard AS C
WHERE C.FId = A.FCardId
AND C.FCompId = 3472609564237496320

SELECT * FROM TMemberCardAccount

DELETE D 
FROM TMemberPointHist AS D,TMember AS A
WHERE D.FMemId = A.FId
AND A.FCompId != 3472609564237496320

DELETE D 
FROM TMemberCoursePack AS D,TMember AS A
WHERE D.FMemId = A.FId
AND A.FCompId != 3472609564237496320

DELETE D 
FROM TMemberCourseHist AS D,TMember AS A
WHERE D.FMemId = A.FId
AND A.FCompId != 3472609564237496320

DELETE D 
FROM TMemberCourseGoods AS D,TMember AS A
WHERE D.FMemId = A.FId
AND A.FCompId != 3472609564237496320

DELETE D 
FROM TMemberCourse AS D,TMember AS A
WHERE D.FMemId = A.FId
AND A.FCompId != 3472609564237496320

--SELECT * FROM TConsumeBill ORDER BY FBillTime DESC
--SELECT * FROM nskdrf_bak..TConsumeBill ORDER BY FBillTime DESC


SELECT * FROM TMemberCard WHERE FCompId = 3472609564237496320
AND FMemId IN(SELECT FId FROM TMember WHERE FCompId != 3472609564237496320)


    UPDATE TMemberSaleRepay SET FArrearCompId=1 where FArrearCompId = 3472609564237496320 
    UPDATE TMemberCardTypeShare SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TMemberCardTypeSub SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TReportColumnCustom SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TOtherIncomeBill SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TItemBaseComm SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TCourseConsBaseComm SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TMemberCourse SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TItemCommAccumSysTypeGroup SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TItemCommSchemeMaster SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TItemCommissionCost SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TBasicDataChanges SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TCoursePackSaleBaseComm SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TItemDiscountMaster SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TCourseSaleBaseComm SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TMemberCourseHist SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TCourseSub SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TMemberCoursePack SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TItemSub SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TPayAccountSub SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TBasicTypeSub SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TEmpPerfDetailCacheControl# SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TReportParam SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TEmpPerfDetailDateCache# SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TMemberOldTransHist SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TMemberCardOldAcctHist SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TBizLog SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TLoginSession SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TBookingRequest SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TMember SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TBulletin SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TSMSHist SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TMemberPointHist SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TStockInBill SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TEmpPerfDetail# SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TMemberRepay SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TStockOutBill SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TMemberSaleBill SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TMemberArrear SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TMemberCard SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TSystemParamSub SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TEmployeeCommScheme SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TEmployeeSub SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TSystemRemind SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TExpensesBill SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TTakeStockBill SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TMemberCardAcctHist SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TTopFunction SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TTrialControl SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TCompanyImage SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TUserAllowCompany SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TConsumeBill SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TGoodsBaseComm SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TMemberTransHist SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TGoodsDiscountMaster SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TMemberCardTypeBaseComm SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TMemberCardTypeCross SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TInventory SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TOrderBill SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TInventoryHist SET FCompId=1 where FCompId = 3472609564237496320 
    UPDATE TMemberCardTypeCross SET FCrossCompId=1 where FCrossCompId = 3472609564237496320 
    UPDATE TMemberCard SET FSaleCompId=1 where FSaleCompId = 3472609564237496320 
    UPDATE TStockInBill SET FSourceCompId=1 where FSourceCompId = 3472609564237496320 
    
    
    SELECT * FROM TUserAllow
       UPDATE TCompany SET FId=1 where FId = 3472609564237496320 
 