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

149 lines
3.4 KiB

1 year ago
use qingdao_baobeimeng
<EFBFBD><EFBFBD>010<EFBFBD>Ĵ<EFBFBD>ֵ<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>Ѽ<EFBFBD>԰<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD> <EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>008<EFBFBD>Ĵ<EFBFBD>ֵ<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>
SELECT * FROM TPayAccount
BEGIN TRAN
DROP TABLE #Card
DECLARE @NewAcctId BIGINT
DECLARE @OldAcctId BIGINT
SELECT @OldAcctId = 3
SELECT @NewAcctId = 4810956988569965137
DECLARE @CompId BIGINT
SELECT @CompId = dbo.FNCompId('008')
SELECT FCardId INTO #Card
FROM TMemberCard WHERE FCompId = @CompId
UPDATE TMemberCardAccount
SET FAcctId = @NewAcctId
WHERE FCardId IN(SELECT FCardId FROM #Card)
AND FAcctId = @OldAcctId
UPDATE TMemberCardAcctHist
SET FAcctId = @NewAcctId
WHERE FCardId IN(SELECT FCardId FROM #Card)
AND FAcctId = @OldAcctId
UPDATE TMemberCardAcctHist
SET FAcctId = @NewAcctId
WHERE FCardId IN(SELECT FCardId FROM #Card)
AND FAcctId = @OldAcctId
UPDATE A
SET A.FPayTypeId = @NewAcctId
FROM TConsumeItemPayment AS A
WHERE A.FCardId IN(SELECT FCardId FROM #Card)
AND A.FPayTypeId = @OldAcctId
UPDATE A
SET A.FOutAcctId = @NewAcctId
FROM TMemberCardTransfer AS A
WHERE A.FOutCardId IN(SELECT FCardId FROM #Card)
AND A.FOutAcctId = @OldAcctId
UPDATE A
SET A.FInAcctId = @NewAcctId
FROM TMemberCardTransfer AS A
WHERE A.FInCardId IN(SELECT FCardId FROM #Card)
AND A.FInAcctId = @OldAcctId
UPDATE A
SET A.FPayTypeId = @NewAcctId
FROM TConsumeGoodsPayment AS A
WHERE A.FCardId IN(SELECT FCardId FROM #Card)
AND A.FPayTypeId = @OldAcctId
UPDATE A
SET A.FPayTypeId = @NewAcctId
FROM TMemberSalePayment AS A, TMemberSaleBill AS B
WHERE B.FPayCardId IN(SELECT FCardId FROM #Card)
AND B.FBillId = A.FBillId
AND A.FPayTypeId = @OldAcctId
UPDATE A
SET A.FAcctId = @NewAcctId
FROM TMemberSaleCard AS A
WHERE A.FCardId IN(SELECT FCardId FROM #Card)
AND A.FAcctId = @OldAcctId
UPDATE A
SET A.FAcctId2 = @NewAcctId
FROM TMemberSaleCard AS A
WHERE A.FCardId IN(SELECT FCardId FROM #Card)
AND A.FAcctId2 = @OldAcctId
UPDATE A
SET A.FContentId = @NewAcctId
FROM TMemberArrear AS A
WHERE A.FCardId IN(SELECT FCardId FROM #Card)
AND A.FContentType = 'Account'
AND A.FContentId = @OldAcctId
SELECT * FROM TMemberCard WHERE FCompId = dbo.FNCompId('008')
AND FCardId IN(SELECT FCardId FROM TConsumeBill)
COMMIT TRAN
SELECT object_name(id),* FROM syscolumns WHERE name LIKE '%PayTypeId%'
AND id in(SELECT id FROM sysobjects WHERE type = 'U')
SELECT * FROM TConsumeItemPayment AS A,TConsumeBill AS B
WHERE A.FBillId = B.FBillId
AND A.FCardId != B.FCardId
AND A.FPayTypeId = 3
AND A.FCardId != 0
AND B.FState = 1
SELECT dbo.FNCompNo(3472618360330518528,4783372590201006601)
SELECT * FROM TMemberCard WHERE FCardId IN(4779220349617985375,4783372590201006601)
SELECT * FROM TSystemParam WHERE FKey LIKE '%Multi%'
UPDATE A
SET A.FCardId = B.FCardId,
A.FCardTypeId = B.FCardTypeId
FROM TConsumeItemPayment AS A,TConsumeBill AS B
WHERE A.FBillId = B.FBillId
AND A.FPayTypeId != 6
UPDATE A
SET A.FCardId = B.FCardId,
A.FCardTypeId = B.FCardTypeId
FROM TConsumeGoodsPayment AS A,TConsumeBill AS B
WHERE A.FBillId = B.FBillId
AND A.FPayTypeId != 6
UPDATE A
SET A.FCardId = C.FMemCourseId,
A.FCardTypeId = 0
FROM TConsumeItemPayment AS A,TConsumeBill AS B,TConsumeItem AS C
WHERE A.FBillId = B.FBillId
AND A.FDetailId = C.FId
AND A.FPayTypeId = 6