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/拉斐/SQLQuery1.sql

128 lines
6.5 KiB

1 year ago
SELECT * FROM TMemberCardEx WHERE FCompName = '--' OR FType = '<EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>'
DELETE master..TMemberEx WHERE LEN(FId) > 20
DELETE master..TMemberCardEx WHERE LEN(FMemId) > 20
DELETE master..TMemberTransHistEx WHERE LEN(FMemId) > 20
ALTER TABLE MASTER..TMemberEx ADD FCompId BIGINT DEFAULT 0 NOT NULL
ALTER TABLE MASTER..TMemberCardEx ADD FCompId BIGINT DEFAULT 0 NOT NULL
ALTER TABLE MASTER..TMemberTransHistEx ADD FCompId BIGINT DEFAULT 0 NOT NULL
ALTER TABLE master..TMemberCardEx ADD FId BIGINT DEFAULT 0 NOT NULL
ALTER TABLE master..TMemberCardEx ADD FTypeId BIGINT DEFAULT 0 NOT NULL
ALTER TABLE MASTER..TMemberEx ADD FNewMemId BIGINT DEFAULT 0 NOT NULL
ALTER TABLE MASTER..TMemberCardEx ADD FNewMemId BIGINT DEFAULT 0 NOT NULL
ALTER TABLE MASTER..TMemberTransHistEx ADD FNewMemId BIGINT DEFAULT 0 NOT NULL
UPDATE master..TMemberEx SET FGender = Case WHEN FGender = '<EFBFBD><EFBFBD>' THEN 1 ELSE 0 END
UPDATE master..TMemberEx SET FCompId = 1
UPDATE master..TMemberCardEx SET FId = dbo.FNGetNewId()
SELECT * FROM TMemberEx WHERE FNewMemId NOT IN (SELECT FId FROM db1.QingDao_LaFeiPaiRui.dbo.TMember)
UPDATE master..TMemberEx SET FNewMemId = abs(CAST( CAST(CAST( FId as UNIQUEIDENTIFIER ) AS BINARY(16)) AS BIGINT) ) WHERE LEN(FId) > 20
UPDATE master..TMemberCardEx SET FNewMemId = abs(CAST( CAST(CAST( FMemId as UNIQUEIDENTIFIER ) AS BINARY(16)) AS BIGINT) )
UPDATE master..TMemberCardEx SET FId = saidao.dbo.FNGetNewId()
UPDATE master..TMemberCardEx SET FCompId = 1
UPDATE master..TMemberCardEx SET FTypeId = (select FId FROM db1.QingDao_LaFeiPaiRui.dbo.TMemberCardType WHERE FNo='46' ) WHERE FType ='1680ϴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE master..TMemberCardEx SET FTypeId = (select FId FROM db1.QingDao_LaFeiPaiRui.dbo.TMemberCardType WHERE FNo='47' ) WHERE FType ='880 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE master..TMemberCardEx SET FTypeId = (select FId FROM db1.QingDao_LaFeiPaiRui.dbo.TMemberCardType WHERE FNo='JFK' ) WHERE FType ='<EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>'
UPDATE master..TMemberCardEx SET FBalance = REPLACE(REPLACE(REPLACE(REPLACE(FBalance,'Ԫ',''),'<EFBFBD>c',''),'<EFBFBD><EFBFBD>',''),',','')
UPDATE master..TMemberTransHistEx SET FNewMemId = abs(CAST( CAST(CAST( FMemId as UNIQUEIDENTIFIER ) AS BINARY(16)) AS BIGINT) )
UPDATE A SET A.FCompId = (SELECT C.FId FROM TCompany AS C WHERE C.FName LIKE '%' + A.FCompName + '%')
FROM master..TMemberTransHistEx AS A
SELECT * FROM master..TMemberEx
SELECT * FROM master..TMemberEx
SELECT * FROM master..TMemberCardEx WHERE FMemId = '{C7C12223-6F43-4E09-9F11-90F50F04F978}'
SELECT A.FMemId,SUM(1) FROM master..TMemberCardEx AS A GROUP BY A.FMemId
SELECT * FROM master..TMemberEx WHERE FName = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
SELECT * FROM master..TMemberTransHistEx
SELECT * FROM TMemberCardAcctHist
INSERT INTO db1.QingDao_LaFeiPaiRui.dbo.TMemberCard(FId,FNo,FFaceNo,FTypeId,FValueType,FCompId,FMemId,FState,FCreateDate,FExpiredDate,FTotalTimes,FUsedTimes,FPoint,FSaleCompId,FSaleBillId,FMemo)
SELECT A.FId,A.FNo,A.FNo, A.FTypeId,1,A.FCompId,A.FNewMemId,1,GETDATE(),A.FExpiredDate,0,0,0,1,0,''
FROM master..TMemberCardEx AS A
WHERE FMemId = '{AA65C156-62EB-4E0F-A8B9-7F915361E442}'
WHERE FNo NOT IN(SELECT FNo FROM db1.QingDao_LaFeiPaiRui.dbo.TMemberCard)
INSERT INTO db1.QingDao_LaFeiPaiRui.dbo.TMember(FId,FNo,FName,FBriefCode,FTypeId,FCompId,FCreateDate,FGender,FBirthdayType,FBirthday,FTelephone,FMobilePhone,FQQ,FWeChat,FIdCard,FEmail,FAddress,FProId,FCPW,FQPW,FChargeEmpId,FPoint,FRecvConsSMS,FRecvBulkSMS,FMemo,FCustom1,FCustom2,FCustom3,FCustom4,FCustom5)
select A.FNewMemId,A.FNewMemId,A.FName,saidao.dbo.FNGetFirstPinYin(A.FName),0,A.FCompId,GETDATE(),A.FGender,'G',A.FBirthday,A.FTelephone,A.FMobilePhone,'','','','','',0,'','',0,0,1,1,'','','','','',''
FROM master..TMemberEx AS A
WHERE FId = '{AA65C156-62EB-4E0F-A8B9-7F915361E442}'
INSERT db1.QingDao_LaFeiPaiRui.dbo.TMemberCardAccount(FId,FCardId,FAcctId,FCreateDate,FExpiredDate,FBalance,FArrear,FMemo)
SELECT saidao.dbo.FNGetNewId(),A.FId,3,GETDATE(),null,cast( REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(FBalance,'Ԫ',''),'<EFBFBD>c',''),',',''),'.00',''),'<EFBFBD><EFBFBD>','')as float) ,0,'<EFBFBD><EFBFBD>ϵͳʣ<EFBFBD><EFBFBD>:' +FBalance
FROM master..TMemberCardEx AS A
WHERE FMemId = '{AA65C156-62EB-4E0F-A8B9-7F915361E442}'
WHERE FId IN (SELECT FId FROM db1.QingDao_LaFeiPaiRui.dbo.TMemberCard WHERE FId NOT IN( SELECT FCardId FROM db1.QingDao_LaFeiPaiRui.dbo.TMemberCardAccount))
WHERE FCompName = '--'
SELECT * FROM
UPDATE master..TMemberTransHistEx SET FCompId = (SELECT FId FROM db1.QingDao_LaFeiPaiRui.dbo.TCompany WHERE FNo = '')
INSERT db1.QingDao_LaFeiPaiRui.dbo.TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
SELECT saidao.dbo.FNGetNewId(),A.FNewMemId,A.FDate,4,A.FCompId,'','','',A.FContent,0,1,REPLACE(A.FAmount,',',''),'',A.FEmployee,''
FROM master..TMemberTransHistEx AS A
WHERE FCompName = '--'
INSERT db1.QingDao_LaFeiPaiRui.dbo.TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
SELECT saidao.dbo.FNGetNewId(),A.FNewMemId,A.FId,3,GETDATE(),A.FTypeId,A.FCompId,'DR','Import',0,'',cast( REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(FBalance,'Ԫ',''),'<EFBFBD>c',''),',',''),'.00',''),'<EFBFBD><EFBFBD>','')as float) ,0,cast( REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(FBalance,'Ԫ',''),'<EFBFBD>c',''),',',''),'.00',''),'<EFBFBD><EFBFBD>','')as float) ,0,GETDATE(),''
FROM master..TMemberCardEx AS A
WHERE FId IN (SELECT FId FROM db1.QingDao_LaFeiPaiRui.dbo.TMemberCard WHERE FId NOT IN( SELECT FCardId FROM db1.QingDao_LaFeiPaiRui.dbo.TMemberCardAcctHist))
WHERE FCompName = '--'
UPDATE A
SET A.FCardId = B.FId
FROM db1.QingDao_LaFeiPaiRui.dbo.TMemberOldTransHist AS A,TMemberCard AS B
WHERE A.FMemId = B.FMemId
UPDATE A
SET A.FNo = B.FNo
FROM db1.QingDao_LaFeiPaiRui.dbo.TMember AS A,TMemberCard AS B
WHERE A.FId = B.FMemId
AND LEN(A.FId) > 18
SELECT A.*,B.* FROM master..TMemberCardex AS B,master..TMemberEx AS A WHERE A.FId = B.FMemId
SELECT * FROM db1.QingDao_LaFeiPaiRui.dbo.TMember WHERE FId= 7861659767801795281
SELECT * FROM db1.QingDao_LaFeiPaiRui.dbo.TMemberCARD WHERE FMemId = 5171550751846841971
SELECT * FROM TMemberEx WHERE FNewMemId NOT in(select FId FROM db1.QingDao_LaFeiPaiRui.dbo.TMember)
SELECT * FROM TMemberCardEx WHERE FNo IN(SELECT FNo FROM db1.QingDao_LaFeiPaiRui.dbo.TMemberCARD WHERE FTypeId =0)
AND FType = '<EFBFBD><EFBFBD>-168<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
SELECT * FROM TMemberEx WHERE FId = '{89F25D94-5017-4B00-97DD-AF5269A54923}'
SELECT * FROM TMemberEx WHERE FName IN( '<EFBFBD>Ի<EFBFBD>','<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
SELECT * FROM TMemberCardEx WHERE FMemId = '{89F25D94-5017-4B00-97DD-AF5269A54923}'