You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sql-tools/Import/昂首/分离数据.sql

92 lines
3.1 KiB

1 year ago
DELETE TBasicTypeSub
DELETE TBasicType
DELETE TSystemParam
EXEC PCopyTable 'TSystemParam','sz24.QingDao_AngShou.dbo.TSystemParam',' '
EXEC PCopyTable 'TItem','sz24.QingDao_AngShou.dbo.TItem',' AND FId > 0 '
EXEC PCopyTable 'TGoods','sz24.QingDao_AngShou.dbo.TItem',' AND FId > 0 '
EXEC PCopyTable 'TBasicType','sz24.QingDao_AngShou.dbo.TBasicType',' '
EXEC PCopyTable 'TMemberCardType','sz24.QingDao_AngShou.dbo.TMemberCardType',' AND FId > 6 '
EXEC PCopyTable 'TImpMember','sz24.QingDao_AngShou.dbo.TImpMember',' '
SELECT * INTO TImpMember FROM sz24.QingDao_AngShou.dbo.TImpMember
EXEC PCopyTable 'TItemBaseComm','sz24.QingDao_AngShou.dbo.TItemBaseComm',' '
UPDATE TItemBaseComm SET FCOmpId = 1
DELETE TItemBaseComm WHERE FCompId != 3472330288284041216
EXEC PCopyTable 'TItemDiscountMaster','sz24.QingDao_AngShou.dbo.TItemDiscountMaster',' AND FCompId = 3472330288284041216 '
EXEC PCopyTable 'TItemDiscountMid','sz24.QingDao_AngShou.dbo.TItemDiscountMid',' AND FParentId IN(SELECT FId FROM TItemDiscountMaster) '
EXEC PCopyTable 'TItemDiscountDetail','sz24.QingDao_AngShou.dbo.TItemDiscountDetail',' AND FParentId IN(SELECT FId FROM TItemDiscountMid) '
UPDATE TItemDiscountMaster SET FCompId = 1
EXEC PCopyTable 'TItem','sz24.QingDao_AngShou.dbo.TItem',' AND FId > 0 '
EXEC PCopyTable 'TEmployee','sz24.QingDao_AngShou.dbo.TEmployee',' AND FNo IN(
''01'',
''06'',
''010'',
''012'',
''04'') '
DROP TABLE #Card
SELECT FMemId,FCardId INTO #Card FROM sz24.QingDao_MuBei.dbo.TMemberCard WHERE FBizEmpId IN(
SELECT FId FROM TEmployee WHERE FNo IN(
'01',
'06',
'010',
'012',
'04')
)
use QingDao_AngShou
EXEC PCopyTable 'TMember','sz24.QingDao_MuBei.dbo.TMember' ,' AND FMemId IN(SELECT FMemId FROM #Card)'
EXEC PCopyTable 'TMemberCard','sz24.QingDao_MuBei.dbo.TMemberCard' ,' AND FCardId IN(SELECT FCardId FROM #Card)'
EXEC PCopyTable 'TMemberCardAccount','sz24.QingDao_MuBei.dbo.TMemberCardAccount' ,' AND FCardId IN(SELECT FCardId FROM #Card)'
EXEC PCopyTable 'TMemberCardAcctHist','sz24.QingDao_MuBei.dbo.TMemberCardAcctHist' ,' AND FCardId IN(SELECT FCardId FROM #Card)'
EXEC PCopyTable 'TMemberTransHist','sz24.QingDao_MuBei.dbo.TMemberTransHist' ,' AND FMemId IN(SELECT FMemId FROM #Card)'
EXEC PCopyTable 'TMemberArrear','sz24.QingDao_MuBei.dbo.TMemberArrear' ,' AND FMemId IN(SELECT FMemId FROM #Card)'
EXEC PCopyTable 'TMemberCardOldAcctHist','sz24.QingDao_MuBei.dbo.TMemberCardOldAcctHist' ,' AND FCardId IN(SELECT FCardId FROM #Card)'
EXEC PCopyTable 'TMemberOldTransHist','sz24.QingDao_MuBei.dbo.TMemberOldTransHist' ,' AND FMemId IN(FMemId FCardId FROM #Card)'
UPDATE TMember SET FCompId = 1
UPDATE TMemberCard SET FCompId = 1
UPDATE A SET A.FCardNo = FCardNo + '<EFBFBD><EFBFBD>ɾ',FDeleted = 1
FROM sz24.QingDao_MuBei.dbo.TMemberCard AS A WHERE A.FCardId IN(SELECT FCardId FROM #Card)
UPDATE A SET A.FMemNo = FMemNo + '<EFBFBD><EFBFBD>ɾ',FDeleted = 1
FROM sz24.QingDao_MuBei.dbo.TMember AS A WHERE A.FMemId IN(SELECT FMemId FROM #Card)
AND FMemId NOT IN(SELECT FMemId FROM sz24.QingDao_MuBei.dbo.TMemberCard WHERE FDeleted = 0)
SELECT * FROM TEmployeeSub
INSERT TEmployeeSub(FEmpId,FCompId,FSerialNo)
SELECT FId,1,FNo
FROM TEmployee
use QingDao_AngShou
SELECT * FROM