


EXEC PCopyTable 'TMemberCardType','db108.LaiZhou_MangGuo.dbo.TMemberCardType',' AND FNo LIKE ''B%'''
EXEC PCopyTable 'TMemberCardTypeSub','db108.LaiZhou_MangGuo.dbo.TMemberCardTypeSub',' AND FCardTypeId IN(SELECT FId FROM TMemberCardType) '

EXEC PCopyTable 'TEmployee','db108.LaiZhou_MangGuo.dbo.TEmployee',' AND FId > 0 AND FId IN(SELECT FEmpId FROM db108.LaiZhou_MangGuo.dbo.TEmployeeSub WHERE FCompId =  5811579782769424104)'
EXEC PCopyTable 'TEmployeeSub','db108.LaiZhou_MangGuo.dbo.TEmployeeSub',' AND FCompId =  5811579782769424104 '

EXEC PCopyTable 'TGoods','db108.LaiZhou_MangGuo.dbo.TGoods',' AND FId > 0 AND FId IN(SELECT FGoodsId FROM db108.LaiZhou_MangGuo.dbo.TGoodsSub WHERE FCompId =  5811579782769424104)'
EXEC PCopyTable 'TGoodsSub','db108.LaiZhou_MangGuo.dbo.TGoodsSub',' AND FCompId =  5811579782769424104 '

EXEC PCopyTable 'TBasicType','db108.LaiZhou_MangGuo.dbo.TBasicType',' AND FId > 0 AND FKey = ''GoodsType'' AND FNo LIKE ''B%'''

 EXEC PCopyTable 'TBasicType','db108.LaiZhou_MangGuo.dbo.TBasicType',' AND FId > 0 AND FKey = ''GoodsDiscountType'' AND FNo LIKE ''B%'''
 EXEC PCopyTable 'TBasicType','db108.LaiZhou_MangGuo.dbo.TBasicType',' AND FId > 0 AND FKey = ''GoodsUnit'' AND FId NOT IN(SELECT FId FROM TBasicType WHERE FKey = ''GoodsUnit'')'

 EXEC PCopyTable 'TBasicType','db108.LaiZhou_MangGuo.dbo.TBasicType',' AND FId IN(5282734014528064530,5751029258359885837,5210826727316260403)'

 EXEC PCopyTable 'TInventory','db108.LaiZhou_MangGuo.dbo.TInventory',' AND FCompId = 5811579782769424104'

SELECT * FROM TCompany 

UPDATE TCompany SET FId = 5811579782769424104 where FId = 5209110196695523061

DELETE TCompanyTree 

SELECT * FROM sys.objects WHERE name like 'TMember%'
ORDER BY name 

sp_helptext PChangeCenterCompany


 EXEC PCopyTable 'TMember','db108.LaiZhou_MangGuo.dbo.TMember',' AND FCompId = 5811579782769424104'
 EXEC PCopyTable 'TMemberCard','db108.LaiZhou_MangGuo.dbo.TMemberCard',' AND FCompId = 5811579782769424104'
 EXEC PCopyTable 'TMemberCardAccount','db108.LaiZhou_MangGuo.dbo.TMemberCardAccount',' AND FMemId IN (SELECT FMemId FROM TMember WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberCardAcctHist','db108.LaiZhou_MangGuo.dbo.TMemberCardAcctHist',' AND FMemId IN (SELECT FMemId FROM TMember WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberTransHist','db108.LaiZhou_MangGuo.dbo.TMemberTransHist',' AND FMemId IN (SELECT FMemId FROM TMember WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberCardAcctHist','db108.LaiZhou_MangGuo.dbo.TMemberCardAcctHist',' AND FMemId IN (SELECT FMemId FROM TMember WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberArrear','db108.LaiZhou_MangGuo.dbo.TMemberArrear',' AND FMemId IN (SELECT FMemId FROM TMember WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberCardMerge','db108.LaiZhou_MangGuo.dbo.TMemberCardMerge',' AND FMemId IN (SELECT FMemId FROM TMember WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberCardMergeDetail','db108.LaiZhou_MangGuo.dbo.TMemberCardMergeDetail',' AND FMemId IN (SELECT FMemId FROM TMember WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberCardTransfer','db108.LaiZhou_MangGuo.dbo.TMemberCardTransfer',' AND FMemId IN (SELECT FMemId FROM TMember WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberChangeLog','db108.LaiZhou_MangGuo.dbo.TMemberChangeLog',' AND FMemId IN (SELECT FMemId FROM TMember WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberCourse','db108.LaiZhou_MangGuo.dbo.TMemberCourse',' AND FMemId IN (SELECT FMemId FROM TMember WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberPhoto','db108.LaiZhou_MangGuo.dbo.TMemberPhoto',' AND FMemId IN (SELECT FMemId FROM TMember WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberPointHist','db108.LaiZhou_MangGuo.dbo.TMemberPointHist',' AND FMemId IN (SELECT FMemId FROM TMember WHERE FCompId = 5811579782769424104)'


SELECT ' EXEC PCopyTable ''' + name + ''',''db108.LaiZhou_MangGuo.dbo.' + name + ''','' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TMemberSaleBill WHERE FCompId = 5811579782769424104)'''   FROM sys.objects
 WHERE name like 'TMemberSale%'
ORDER BY name 

 EXEC PCopyTable 'TMemberSaleBill','db108.LaiZhou_MangGuo.dbo.TMemberSaleBill',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TMemberSaleBill WHERE FCompId = 5811579782769424104)' 
  EXEC PCopyTable 'TMemberSaleCard','db108.LaiZhou_MangGuo.dbo.TMemberSaleCard',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TMemberSaleBill WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberSaleCombo','db108.LaiZhou_MangGuo.dbo.TMemberSaleCombo',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TMemberSaleBill WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberSaleCourse','db108.LaiZhou_MangGuo.dbo.TMemberSaleCourse',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TMemberSaleBill WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberSaleCourseGoods','db108.LaiZhou_MangGuo.dbo.TMemberSaleCourseGoods',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TMemberSaleBill WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberSaleCoursePack','db108.LaiZhou_MangGuo.dbo.TMemberSaleCoursePack',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TMemberSaleBill WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberSaleDetailPayment','db108.LaiZhou_MangGuo.dbo.TMemberSaleDetailPayment',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TMemberSaleBill WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberSaleDetailSplit','db108.LaiZhou_MangGuo.dbo.TMemberSaleDetailSplit',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TMemberSaleBill WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberSaleEmployee','db108.LaiZhou_MangGuo.dbo.TMemberSaleEmployee',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TMemberSaleBill WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberSaleExchange','db108.LaiZhou_MangGuo.dbo.TMemberSaleExchange',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TMemberSaleBill WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberSaleExchangeSource','db108.LaiZhou_MangGuo.dbo.TMemberSaleExchangeSource',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TMemberSaleBill WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberSaleFreeItem','db108.LaiZhou_MangGuo.dbo.TMemberSaleFreeItem',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TMemberSaleBill WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberSaleInfo','db108.LaiZhou_MangGuo.dbo.TMemberSaleInfo',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TMemberSaleBill WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TMemberSalePayment','db108.LaiZhou_MangGuo.dbo.TMemberSalePayment',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TMemberSaleBill WHERE FCompId = 5811579782769424104)'
 
 EXEC PCopyTable 'TMemberSaleRepay','db108.LaiZhou_MangGuo.dbo.TMemberSaleRepay',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TMemberSaleBill WHERE FCompId = 5811579782769424104)'
 
 SELECT ' EXEC PCopyTable ''' + name + ''',''db108.LaiZhou_MangGuo.dbo.' + name + ''','' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TConsumeBill WHERE FCompId = 5811579782769424104)'''   FROM sys.objects
 WHERE name like 'TConsume%'
ORDER BY name 


 EXEC PCopyTable 'TConsumeBill','db108.LaiZhou_MangGuo.dbo.TConsumeBill',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TConsumeBill WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TConsumeGoods','db108.LaiZhou_MangGuo.dbo.TConsumeGoods',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TConsumeBill WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TConsumeGoodsEmployee','db108.LaiZhou_MangGuo.dbo.TConsumeGoodsEmployee',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TConsumeBill WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TConsumeGoodsPayment','db108.LaiZhou_MangGuo.dbo.TConsumeGoodsPayment',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TConsumeBill WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TConsumeItem','db108.LaiZhou_MangGuo.dbo.TConsumeItem',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TConsumeBill WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TConsumeItemCostGoods','db108.LaiZhou_MangGuo.dbo.TConsumeItemCostGoods',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TConsumeBill WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TConsumeItemEmployee','db108.LaiZhou_MangGuo.dbo.TConsumeItemEmployee',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TConsumeBill WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TConsumeItemPayment','db108.LaiZhou_MangGuo.dbo.TConsumeItemPayment',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TConsumeBill WHERE FCompId = 5811579782769424104)'
 EXEC PCopyTable 'TConsumeReturnVisit','db108.LaiZhou_MangGuo.dbo.TConsumeReturnVisit',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TConsumeBill WHERE FCompId = 5811579782769424104)'
 
 EXEC PCopyTable 'TConsumeReturnVisitLog','db108.LaiZhou_MangGuo.dbo.TConsumeReturnVisitLog',' AND FBillId IN(SELECT FBillId FROM db108.LaiZhou_MangGuo.dbo.TConsumeBill WHERE FCompId = 5811579782769424104)'
 
 
 DELETE TUserAllowCompany WHERE FCompId != 1 
 
 
 SELECT * FROM TBasicType 
 
 UPDATE TGoods SET FDctId = 4996609560410918027
 
 
 D