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/美之家/美之家.sql

119 lines
3.5 KiB

1 year ago
/*
SELECT gca01c AS FCardNo,A.FCardId,A.FMemId,B.FCardId AS FOldCardId
INTO #Card
FROM ZZYINS026..gcm01 AS A,ZZYINS026..gcm03 AS B
WHERE a.gca00c = b.gcc00c
AND a.gca01c = b.gcc01c
AND a.gca00c= a.gca13d
AND A.FCardId != B.FCardId
AND a.gca08i in(4,5,10)
GROUP BY gca01c,A.FCardId,A.FMemId,B.FCardId
SELECT * FROM #Card
*/
DECLARE @CardId BIGINT
DECLARE @MemId BIGINT
DECLARE @CardNO VARCHAR(1000)
DECLARE @OldCardId BIGINT
DECLARE List CURSOR FOR
SELECT FCardNo,FCardId,FMemId,FOldCardId
FROM #Card -- WHERE FCardNo = '527605'
OPEN List
FETCH List INTO @CardNo,@CardId,@MemId,@OldCardId
WHILE @@FETCH_STATUS = 0
BEGIN
UPDATE ZZYINS026..gcm03 SET FMemId = @MemId,FCardId = @CardId
WHERE FCardId = @OldCardId AND gcc01c = @CardNo
UPDATE ZZYINS026..gcm04 SET FMemId = @MemId,FCardId = @CardId
WHERE FCardId = @OldCardId AND gcd01c = @CardNo
UPDATE TBKAccount# SET FMemId = @MemId,FCardId = @CardId
WHERE FCardId = @OldCardId
INSERT INTO TMemberCardAccount(FId,FMemId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
SELECT dbo.FNNewId(),FMemId,FCardId,FAcctId,FBalance,FBalance,FArrear,FCreateDate,NULL,FMemo
FROM TBKAccount#
WHERE FBKAcctId NOT IN(3,4,888,999,889)
--TODO
AND FCardId = @CardId
AND FCardId IN(SELECT FCardId FROM TMemberCard)
INSERT INTO TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
SELECT dbo.FNNewId(),A.FMemId,A.FCardId,A.FAcctId,getdate(),A.FCardTypeId,A.FCompId,'DR','Import',0,'',A.FBalance,0,A.FBalance,A.FArrear,getdate(),''
FROM TBKAccount# AS A
WHERE (A.FBalance != 0 OR A.FArrear > 0)
AND FBKAcctId NOT IN(3,888,999,889)
AND FCardId = @CardId
FETCH List INTO @CardNo,@CardId,@MemId,@OldCardId
END
CLOSE List
DEALLOCATE List
--д<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>
/*
SELECT * FROM TBKMember# WHERE FCardNO = '920487'
SELECT * FROM ZZYINS026..gbm01 WHERE gba01c = '8203008661'
AND gba00c = '047'
SELECT * FROM ZZYINS026..gcm01 WHERE gca01c = '186350'
UPDATE A
SET A.FName = B.gba03c,
A.FMobilePhone = ISNULL(B.gba08c,'')
-- SELECT A.FMemNo,A.FName,A.FMobilePhone,B.gba03c,B.gba08c-- ,D.FName,D.FMobilePhone
FROM TMember AS A,ZZYINS026..gbm01 AS B,ZZYINS026..gcm01 AS C--,_ModifyMember AS D
WHERE C.FMemId = A.FMemId
AND C.gca01c = B.gba01c
AND C.gca00c = B.gba00c
AND C.gca00c = C.gca13d
AND A.FName != B.gba03c
-- AND D.FMemId = A.FMemId
AND A.FMemId NOT IN(SELECT FMemId FROM _ModifyMember)
AND A.FMemId IN(SELECT FMemId FROM TConsumeBill)
-- AND D.FName = A.FName
SELECT * FROM TBKMember# WHERE FMemNO = '8203008661'
SELECT * FROM _ModifyMember AS A,TMember AS B
WHERE A.FMemID = B.FMemId
AND A.FName != B.FName
AND A.FMemId IN(SELECT FMemId FROM TConsumeBill)
SELECT * FROM SELECT * FROM ZZYINS026..gcm01
SELECT * FROM ZZYINS026..gbm01 AS A,d
SELECT gba01c FROM
(
SELECT gba01c,gba03c FROM ZZYINS026..gbm01
GROUP BY gba01c,gba03c
)AS A
GROUP BY gba01c
HAVING(SUM(1) > 1)
*/