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.

2204 lines
58 KiB

1 year ago
CREATE FUNCTION FNAcctId (@AcctNo VARCHAR(10))
RETURNS BIGINT
AS
BEGIN
return (SELECT FId FROM TPayAccount WHERE FNo = @AcctNo)
END
GO
CREATE FUNCTION FNCardTypeId (@No VARCHAR(10))
RETURNS BIGINT
AS
BEGIN
return (SELECT FId FROM TMemberCardType WHERE FNo = @No)
END
GO
--------ģ<EFBFBD><EFBFBD>
-----------------------------------------------------------------
--"Type"<EFBFBD><EFBFBD>
-----------------------------------------------------------------
SELECT * FROM TMemberCardType WHERE FNo = 'CardTypeNo'
SELECT * FROM TPayAccount WHERE FNo = 'AcctNo'
------------------------------------------------------------------
--<EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>ֱ<EFBFBD><EFBFBD>ת
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard"Type"ֱ<EFBFBD><EFBFBD>ת
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE FTypeId = dbo.FNCardTypeId('CardTypeNo')
AND A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND NOT EXISTS(SELECT 1 FROM TMemberCardAccount AS O WHERE O.FCardId = A.FCardId AND O.FAcctId = 3)
AND B.FAcctId = dbo.FNAcctId('AcctNo')
ORDER BY A.FCardNo
SELECT * FROM TCard"Type"ֱ<EFBFBD><EFBFBD>ת
--ת<EFBFBD>˻<EFBFBD>
UPDATE A
SET A.FAcctId = 3
FROM TCard"Type"ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('AcctNo')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard"Type"ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('AcctNo')
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard"Type"ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardOldAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('AcctNo')
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard"Type"ֱ<EFBFBD><EFBFBD>ת)
--<EFBFBD><EFBFBD>Щ<EFBFBD>˻<EFBFBD>ҪתΪ<EFBFBD>¿<EFBFBD>
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard"Type"ת<EFBFBD>¿<EFBFBD>
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND B.FAcctId = dbo.FNAcctId('AcctNo')
ORDER BY A.FCardNo
select * from TCard"Type"ת<EFBFBD>¿<EFBFBD>
--<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardTypeId = dbo.FNCardTypeId('CardTypeNo')
FROM TMemberCardAccount AS A
WHERE FId IN(SELECT FId FROM TCard"Type"ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardNo = B.FCardNo + '.CardTypeNo'
FROM TCard"Type"ת<EFBFBD>¿<EFBFBD> as b, TMemberCardAccount AS A
WHERE B.FId = A.FId
AND A.FAcctId = dbo.FNAcctId('AcctNo')
SELECT * FROM TMemberCardAccount WHERE FId IN(SELECT FId FROM TCard"Type"ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¿<EFBFBD>
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId
)
SELECT
FNewCardId AS FCardId,
FNewCardNo AS FCardNo,
FNewCardNo AS FFaceNo,
FNewCardTypeId AS FTypeId,
1,
FNewCardCompId AS FCompId,
FMemId AS FMemId,
FNewCardState AS FState,
FNewCardCreateDate AS FCreateDate,
FNewCardExpiredDate AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FNewCardCompId AS FSaleCompId,
0 AS FSaleBillId
FROM TMemberCardAccount
WHERE FId IN(SELECT FId FROM TCard"Type"ת<EFBFBD>¿<EFBFBD>)
UPDATE A
SET A.FAcctId = 3,
A.FCardId = A.FNewCardId
FROM TCard"Type"ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('AcctNo')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard"Type"ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('AcctNo')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard"Type"ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardOldAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('AcctNo')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard"Type"ת<EFBFBD>¿<EFBFBD>)
-----------------------------------------------------------------------------------
--End OF ģ<EFBFBD><EFBFBD>
----------------------------------------------------------------------------------
SELECT * FROM TPayAccount
SELECT A.FCardId,C.FCardNo,B.FNo,B.FName,P.FNo,P.FName
FROM TMemberCardAccount AS A,TMemberCard AS C,TPayAccount AS P,
TMemberCardType AS B
WHERE A.FCardId = C.FCardId
AND C.FTypeId = B.FId
AND P.FId = A.FAcctId
ORDER BY C.FCardNo
SELECT * FROM TConsumeBill
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¿<EFBFBD>ID
ALTER TABLE TMemberCardAccount ADD FNewCardId BIGINT
ALTER TABLE TMemberCardAccount ADD FNewCardNo VARCHAR(50)
ALTER TABLE TMemberCardAccount ADD FNewCardTypeId BIGINT
ALTER TABLE TMemberCardAccount ADD FNewCardExpiredDate DATETIME
ALTER TABLE TMemberCardAccount ADD FNewCardCreateDate DATETIME
ALTER TABLE TMemberCardAccount ADD FNewCardState INT
ALTER TABLE TMemberCardAccount ADD FNewCardCompId BIGINT
ALTER TABLE TMemberCardAccount ADD FOldCardId BIGINT
UPDATE A
SET A.FNewCardExpiredDate = B.FExpiredDate,
A.FNewCardCreateDate = B.FCreateDate,
A.FNewCardState = B.FState,
A.FNewCardCompId = B.FCompId
FROM TMemberCardAccount AS A,TMemberCard AS B
WHERE A.FCardId = B.FCardId
UPDATE TMemberCardAccount SET FNewCardId = FId
UPDATE TMemberCardAccount SET FOldCardId = FCardId
SP_RENAME 'TMemberCardAccount.FOlcCardId','FOldCardId'
SELECT * FROM TMemberCardType WHERE FNo = 'D'
SELECT*FROM TConsumeBill
SELECT * INTO TMemberCardAccount_Bak FROM TMemberCardAccount
SELECT * INTO TMemberCardAcctHist_Bak FROM TMemberCardAcctHist
SELECT * INTO TMemberCard_Bak FROM TMemberCard
-----------------------------------------------------------------
--1000<EFBFBD><EFBFBD>
-----------------------------------------------------------------
SELECT * FROM TMemberCardType WHERE FNo = 'D'
SELECT * FROM TPayAccount WHERE FNo = 'J'
------------------------------------------------------------------
--<EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>ֱ<EFBFBD><EFBFBD>ת
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard1000ֱ<EFBFBD><EFBFBD>ת
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE FTypeId = dbo.FNCardTypeId('D')
AND A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND NOT EXISTS(SELECT 1 FROM TMemberCardAccount AS O WHERE O.FCardId = A.FCardId AND O.FAcctId = 3)
AND B.FAcctId = dbo.FNAcctId('J')
ORDER BY A.FCardNo
SELECT * FROM TCard1000ֱ<EFBFBD><EFBFBD>ת
--ת<EFBFBD>˻<EFBFBD>
UPDATE A
SET A.FAcctId = 3
FROM TCard1000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('J')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard1000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('J')
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard1000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardOldAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('J')
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard1000ֱ<EFBFBD><EFBFBD>ת)
--<EFBFBD><EFBFBD>Щ<EFBFBD>˻<EFBFBD>ҪתΪ<EFBFBD>¿<EFBFBD>
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard1000ת<EFBFBD>¿<EFBFBD>
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND B.FAcctId = dbo.FNAcctId('J')
ORDER BY A.FCardNo
select * from TCard1000ת<EFBFBD>¿<EFBFBD>
--<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardTypeId = dbo.FNCardTypeId('D')
FROM TMemberCardAccount AS A
WHERE FId IN(SELECT FId FROM TCard1000ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardNo = B.FCardNo + '.D'
FROM TCard1000ת<EFBFBD>¿<EFBFBD> as b, TMemberCardAccount AS A
WHERE B.FId = A.FId
AND A.FAcctId = dbo.FNAcctId('J')
SELECT * FROM TMemberCardAccount WHERE FId IN(SELECT FId FROM TCard1000ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¿<EFBFBD>
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId
)
SELECT
FNewCardId AS FCardId,
FNewCardNo AS FCardNo,
FNewCardNo AS FFaceNo,
FNewCardTypeId AS FTypeId,
1,
FNewCardCompId AS FCompId,
FMemId AS FMemId,
FNewCardState AS FState,
FNewCardCreateDate AS FCreateDate,
FNewCardExpiredDate AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FNewCardCompId AS FSaleCompId,
0 AS FSaleBillId
FROM TMemberCardAccount
WHERE FId IN(SELECT FId FROM TCard1000ת<EFBFBD>¿<EFBFBD>)
UPDATE A
SET A.FAcctId = 3,
A.FCardId = A.FNewCardId
FROM TCard1000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('J')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard1000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('J')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId
FROM TCard1000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardOldAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('J')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard1000ת<EFBFBD>¿<EFBFBD>)
-----------------------------------------------------------------------------------
--End OF 1000
----------------------------------------------------------------------------------
--------ģ<EFBFBD><EFBFBD>
-----------------------------------------------------------------
--2000<EFBFBD><EFBFBD>
-----------------------------------------------------------------
SELECT * FROM TMemberCardType WHERE FNo = 'E'
SELECT * FROM TPayAccount WHERE FNo = 'K'
------------------------------------------------------------------
--<EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>ֱ<EFBFBD><EFBFBD>ת
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard2000ֱ<EFBFBD><EFBFBD>ת
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE FTypeId = dbo.FNCardTypeId('E')
AND A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND NOT EXISTS(SELECT 1 FROM TMemberCardAccount AS O WHERE O.FCardId = A.FCardId AND O.FAcctId = 3)
AND B.FAcctId = dbo.FNAcctId('K')
ORDER BY A.FCardNo
SELECT * FROM TCard2000ֱ<EFBFBD><EFBFBD>ת
--ת<EFBFBD>˻<EFBFBD>
UPDATE A
SET A.FAcctId = 3
FROM TCard2000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('K')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard2000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('K')
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard2000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardOldAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('K')
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard2000ֱ<EFBFBD><EFBFBD>ת)
--<EFBFBD><EFBFBD>Щ<EFBFBD>˻<EFBFBD>ҪתΪ<EFBFBD>¿<EFBFBD>
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard2000ת<EFBFBD>¿<EFBFBD>
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND B.FAcctId = dbo.FNAcctId('K')
ORDER BY A.FCardNo
select * from TCard2000ת<EFBFBD>¿<EFBFBD>
--<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardTypeId = dbo.FNCardTypeId('E')
FROM TMemberCardAccount AS A
WHERE FId IN(SELECT FId FROM TCard2000ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardNo = B.FCardNo + '.E'
FROM TCard2000ת<EFBFBD>¿<EFBFBD> as b, TMemberCardAccount AS A
WHERE B.FId = A.FId
AND A.FAcctId = dbo.FNAcctId('K')
SELECT * FROM TMemberCardAccount WHERE FId IN(SELECT FId FROM TCard2000ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¿<EFBFBD>
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId
)
SELECT
FNewCardId AS FCardId,
FNewCardNo AS FCardNo,
FNewCardNo AS FFaceNo,
FNewCardTypeId AS FTypeId,
1,
FNewCardCompId AS FCompId,
FMemId AS FMemId,
FNewCardState AS FState,
FNewCardCreateDate AS FCreateDate,
FNewCardExpiredDate AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FNewCardCompId AS FSaleCompId,
0 AS FSaleBillId
FROM TMemberCardAccount
WHERE FId IN(SELECT FId FROM TCard2000ת<EFBFBD>¿<EFBFBD>)
UPDATE A
SET A.FAcctId = 3,
A.FCardId = A.FNewCardId
FROM TCard2000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('K')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard2000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('K')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard2000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardOldAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('K')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard2000ת<EFBFBD>¿<EFBFBD>)
-----------------------------------------------------------------------------------
--End OF 2000
----------------------------------------------------------------------------------
-----------------------------------------------------------------
--3600<EFBFBD><EFBFBD>
-----------------------------------------------------------------
SELECT * FROM TMemberCardType WHERE FNo = 'F'
SELECT * FROM TPayAccount WHERE FNo = 'L'
------------------------------------------------------------------
--<EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>ֱ<EFBFBD><EFBFBD>ת
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard3600ֱ<EFBFBD><EFBFBD>ת
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE FTypeId = dbo.FNCardTypeId('F')
AND A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND NOT EXISTS(SELECT 1 FROM TMemberCardAccount AS O WHERE O.FCardId = A.FCardId AND O.FAcctId = 3)
AND B.FAcctId = dbo.FNAcctId('L')
ORDER BY A.FCardNo
SELECT * FROM TCard3600ֱ<EFBFBD><EFBFBD>ת
--ת<EFBFBD>˻<EFBFBD>
UPDATE A
SET A.FAcctId = 3
FROM TCard3600ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('L')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard3600ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('L')
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard3600ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardOldAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('L')
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard3600ֱ<EFBFBD><EFBFBD>ת)
--<EFBFBD><EFBFBD>Щ<EFBFBD>˻<EFBFBD>ҪתΪ<EFBFBD>¿<EFBFBD>
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard3600ת<EFBFBD>¿<EFBFBD>
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND B.FAcctId = dbo.FNAcctId('L')
ORDER BY A.FCardNo
select * from TCard3600ת<EFBFBD>¿<EFBFBD>
--<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardTypeId = dbo.FNCardTypeId('F')
FROM TMemberCardAccount AS A
WHERE FId IN(SELECT FId FROM TCard3600ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardNo = B.FCardNo + '.F'
FROM TCard3600ת<EFBFBD>¿<EFBFBD> as b, TMemberCardAccount AS A
WHERE B.FId = A.FId
AND A.FAcctId = dbo.FNAcctId('L')
SELECT * FROM TMemberCardAccount WHERE FId IN(SELECT FId FROM TCard3600ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¿<EFBFBD>
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId
)
SELECT
FNewCardId AS FCardId,
FNewCardNo AS FCardNo,
FNewCardNo AS FFaceNo,
FNewCardTypeId AS FTypeId,
1,
FNewCardCompId AS FCompId,
FMemId AS FMemId,
FNewCardState AS FState,
FNewCardCreateDate AS FCreateDate,
FNewCardExpiredDate AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FNewCardCompId AS FSaleCompId,
0 AS FSaleBillId
FROM TMemberCardAccount
WHERE FId IN(SELECT FId FROM TCard3600ת<EFBFBD>¿<EFBFBD>)
UPDATE A
SET A.FAcctId = 3,
A.FCardId = A.FNewCardId
FROM TCard3600ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('L')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard3600ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('L')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard3600ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardOldAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('L')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard3600ת<EFBFBD>¿<EFBFBD>)
-----------------------------------------------------------------------------------
--End OF 3600
----------------------------------------------------------------------------------
-----------------------------------------------------------------
--6000<EFBFBD><EFBFBD>
-----------------------------------------------------------------
SELECT * FROM TMemberCardType WHERE FNo = 'G'
SELECT * FROM TPayAccount WHERE FNo = 'M'
------------------------------------------------------------------
--<EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>ֱ<EFBFBD><EFBFBD>ת
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard6000ֱ<EFBFBD><EFBFBD>ת
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE FTypeId = dbo.FNCardTypeId('G')
AND A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND NOT EXISTS(SELECT 1 FROM TMemberCardAccount AS O WHERE O.FCardId = A.FCardId AND O.FAcctId = 3)
AND B.FAcctId = dbo.FNAcctId('M')
ORDER BY A.FCardNo
SELECT * FROM TCard6000ֱ<EFBFBD><EFBFBD>ת
--ת<EFBFBD>˻<EFBFBD>
UPDATE A
SET A.FAcctId = 3
FROM TCard6000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('M')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard6000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('M')
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard6000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardOldAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('M')
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard6000ֱ<EFBFBD><EFBFBD>ת)
--<EFBFBD><EFBFBD>Щ<EFBFBD>˻<EFBFBD>ҪתΪ<EFBFBD>¿<EFBFBD>
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard6000ת<EFBFBD>¿<EFBFBD>
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND B.FAcctId = dbo.FNAcctId('M')
ORDER BY A.FCardNo
select * from TCard6000ת<EFBFBD>¿<EFBFBD>
--<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardTypeId = dbo.FNCardTypeId('G')
FROM TMemberCardAccount AS A
WHERE FId IN(SELECT FId FROM TCard6000ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardNo = B.FCardNo + '.G'
FROM TCard6000ת<EFBFBD>¿<EFBFBD> as b, TMemberCardAccount AS A
WHERE B.FId = A.FId
AND A.FAcctId = dbo.FNAcctId('M')
SELECT * FROM TMemberCardAccount WHERE FId IN(SELECT FId FROM TCard6000ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¿<EFBFBD>
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId
)
SELECT
FNewCardId AS FCardId,
FNewCardNo AS FCardNo,
FNewCardNo AS FFaceNo,
FNewCardTypeId AS FTypeId,
1,
FNewCardCompId AS FCompId,
FMemId AS FMemId,
FNewCardState AS FState,
FNewCardCreateDate AS FCreateDate,
FNewCardExpiredDate AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FNewCardCompId AS FSaleCompId,
0 AS FSaleBillId
FROM TMemberCardAccount
WHERE FId IN(SELECT FId FROM TCard6000ת<EFBFBD>¿<EFBFBD>)
UPDATE A
SET A.FAcctId = 3,
A.FCardId = A.FNewCardId
FROM TCard6000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('M')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId
FROM TCard6000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('M')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId
FROM TCard6000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardOldAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('M')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard6000ת<EFBFBD>¿<EFBFBD>)
-----------------------------------------------------------------------------------
--End OF 6000
----------------------------------------------------------------------------------
-----------------------------------------------------------------
--10000<EFBFBD><EFBFBD>
-----------------------------------------------------------------
SELECT * FROM TMemberCardType WHERE FNo = 'H'
SELECT * FROM TPayAccount WHERE FNo = 'N'
------------------------------------------------------------------
--<EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>ֱ<EFBFBD><EFBFBD>ת
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard10000ֱ<EFBFBD><EFBFBD>ת
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE FTypeId = dbo.FNCardTypeId('H')
AND A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND NOT EXISTS(SELECT 1 FROM TMemberCardAccount AS O WHERE O.FCardId = A.FCardId AND O.FAcctId = 3)
AND B.FAcctId = dbo.FNAcctId('N')
ORDER BY A.FCardNo
SELECT * FROM TCard10000ֱ<EFBFBD><EFBFBD>ת
--ת<EFBFBD>˻<EFBFBD>
UPDATE A
SET A.FAcctId = 3
FROM TCard10000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('N')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard10000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('N')
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard10000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardOldAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('N')
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard10000ֱ<EFBFBD><EFBFBD>ת)
--<EFBFBD><EFBFBD>Щ<EFBFBD>˻<EFBFBD>ҪתΪ<EFBFBD>¿<EFBFBD>
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard10000ת<EFBFBD>¿<EFBFBD>
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND B.FAcctId = dbo.FNAcctId('N')
ORDER BY A.FCardNo
select * from TCard10000ת<EFBFBD>¿<EFBFBD>
--<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardTypeId = dbo.FNCardTypeId('H')
FROM TMemberCardAccount AS A
WHERE FId IN(SELECT FId FROM TCard10000ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardNo = B.FCardNo + '.H'
FROM TCard10000ת<EFBFBD>¿<EFBFBD> as b, TMemberCardAccount AS A
WHERE B.FId = A.FId
AND A.FAcctId = dbo.FNAcctId('N')
SELECT * FROM TMemberCardAccount WHERE FId IN(SELECT FId FROM TCard10000ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¿<EFBFBD>
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId
)
SELECT
FNewCardId AS FCardId,
FNewCardNo AS FCardNo,
FNewCardNo AS FFaceNo,
FNewCardTypeId AS FTypeId,
1,
FNewCardCompId AS FCompId,
FMemId AS FMemId,
FNewCardState AS FState,
FNewCardCreateDate AS FCreateDate,
FNewCardExpiredDate AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FNewCardCompId AS FSaleCompId,
0 AS FSaleBillId
FROM TMemberCardAccount
WHERE FId IN(SELECT FId FROM TCard10000ת<EFBFBD>¿<EFBFBD>)
UPDATE A
SET A.FAcctId = 3,
A.FCardId = A.FNewCardId
FROM TCard10000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('N')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard10000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('N')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard10000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardOldAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('N')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard10000ת<EFBFBD>¿<EFBFBD>)
-----------------------------------------------------------------------------------
--End OF 10000
----------------------------------------------------------------------------------
-----------------------------------------------------------------
--20000<EFBFBD><EFBFBD>
-----------------------------------------------------------------
SELECT * FROM TMemberCardType WHERE FNo = 'I'
SELECT * FROM TPayAccount WHERE FNo = 'O'
------------------------------------------------------------------
--<EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>ֱ<EFBFBD><EFBFBD>ת
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard20000ֱ<EFBFBD><EFBFBD>ת
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE FTypeId = dbo.FNCardTypeId('I')
AND A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND NOT EXISTS(SELECT 1 FROM TMemberCardAccount AS O WHERE O.FCardId = A.FCardId AND O.FAcctId = 3)
AND B.FAcctId = dbo.FNAcctId('O')
ORDER BY A.FCardNo
SELECT * FROM TCard20000ֱ<EFBFBD><EFBFBD>ת
--ת<EFBFBD>˻<EFBFBD>
UPDATE A
SET A.FAcctId = 3
FROM TCard20000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('O')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard20000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('O')
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard20000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardOldAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('O')
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard20000ֱ<EFBFBD><EFBFBD>ת)
--<EFBFBD><EFBFBD>Щ<EFBFBD>˻<EFBFBD>ҪתΪ<EFBFBD>¿<EFBFBD>
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard20000ת<EFBFBD>¿<EFBFBD>
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND B.FAcctId = dbo.FNAcctId('O')
ORDER BY A.FCardNo
select * from TCard20000ת<EFBFBD>¿<EFBFBD>
--<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardTypeId = dbo.FNCardTypeId('I')
FROM TMemberCardAccount AS A
WHERE FId IN(SELECT FId FROM TCard20000ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardNo = B.FCardNo + '.I'
FROM TCard20000ת<EFBFBD>¿<EFBFBD> as b, TMemberCardAccount AS A
WHERE B.FId = A.FId
AND A.FAcctId = dbo.FNAcctId('O')
SELECT * FROM TMemberCardAccount WHERE FId IN(SELECT FId FROM TCard20000ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¿<EFBFBD>
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId
)
SELECT
FNewCardId AS FCardId,
FNewCardNo AS FCardNo,
FNewCardNo AS FFaceNo,
FNewCardTypeId AS FTypeId,
1,
FNewCardCompId AS FCompId,
FMemId AS FMemId,
FNewCardState AS FState,
FNewCardCreateDate AS FCreateDate,
FNewCardExpiredDate AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FNewCardCompId AS FSaleCompId,
0 AS FSaleBillId
FROM TMemberCardAccount
WHERE FId IN(SELECT FId FROM TCard20000ת<EFBFBD>¿<EFBFBD>)
UPDATE A
SET A.FAcctId = 3,
A.FCardId = A.FNewCardId
FROM TCard20000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('O')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard20000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('O')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard20000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardOldAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('O')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard20000ת<EFBFBD>¿<EFBFBD>)
-----------------------------------------------------------------------------------
--End OF 20000
----------------------------------------------------------------------------------
-----------------------------------------------------------------
--38000<EFBFBD><EFBFBD>
-----------------------------------------------------------------
SELECT * FROM TMemberCardType WHERE FNo = 'S'
SELECT * FROM TPayAccount WHERE FNo = 'S'
SELECT * FROM TMemberCardAccount WHERE FAcctId= dbo.FNAcctId('S')
------------------------------------------------------------------
--38000Ԫ
--<EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>ֱ<EFBFBD><EFBFBD>ת
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard38000ֱ<EFBFBD><EFBFBD>ת
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE FTypeId = dbo.FNCardTypeId('S')
AND A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND NOT EXISTS(SELECT 1 FROM TMemberCardAccount AS O WHERE O.FCardId = A.FCardId AND O.FAcctId = 3)
AND B.FAcctId = dbo.FNAcctId('S')
ORDER BY A.FCardNo
SELECT * FROM TCard38000ֱ<EFBFBD><EFBFBD>ת
UPDATE A
SET A.FAcctId = 3
FROM TCard38000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('S')
AND A.FId = B.FId
UPDATE A
SET A.FAcctId = 3
FROM TCard38000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('S')
AND A.FId = B.FId
UPDATE A
SET A.FAcctId = 3
FROM TCard38000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardOldAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('S')
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard38000ֱ<EFBFBD><EFBFBD>ת)
--38000<EFBFBD><EFBFBD>Ԫ
--<EFBFBD><EFBFBD>Щ<EFBFBD>˻<EFBFBD>ҪתΪ<EFBFBD>¿<EFBFBD>
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard38000ת<EFBFBD>¿<EFBFBD>
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND B.FAcctId = dbo.FNAcctId('S')
ORDER BY A.FCardNo
select * from TCard38000ת<EFBFBD>¿<EFBFBD>
--<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardTypeId = dbo.FNCardTypeId('S')
FROM TMemberCardAccount AS A
WHERE FId IN(SELECT FId FROM TCard38000ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardNo = B.FCardNo + '.S'
FROM TCard38000ת<EFBFBD>¿<EFBFBD> as b, TMemberCardAccount AS A
WHERE B.FId = A.FId
AND A.FAcctId = dbo.FNAcctId('S')
SELECT * FROM TMemberCardAccount WHERE FId IN(SELECT FId FROM TCard38000ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¿<EFBFBD>
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId
)
SELECT
FNewCardId AS FCardId,
FNewCardNo AS FCardNo,
FNewCardNo AS FFaceNo,
FNewCardTypeId AS FTypeId,
1,
FNewCardCompId AS FCompId,
FMemId AS FMemId,
FNewCardState AS FState,
FNewCardCreateDate AS FCreateDate,
FNewCardExpiredDate AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FNewCardCompId AS FSaleCompId,
0 AS FSaleBillId
FROM TMemberCardAccount
WHERE FId IN(SELECT FId FROM TCard38000ת<EFBFBD>¿<EFBFBD>)
UPDATE A
SET A.FAcctId = 3,
A.FCardId = A.FNewCardId
FROM TCard38000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('S')
AND A.FId = B.FId
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard38000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('S')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard38000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardOldAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('S')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard38000ת<EFBFBD>¿<EFBFBD>)
-----------------------------------------------------------------------------------
--End OF 38000
----------------------------------------------------------------------------------
--UPDATE T
-- SET T.FCardId = C.FNewCardId,
-- T.FCardNo = C.FNewCardNo,
-- T.FCardTypeId = C.FNewCardTypeId
-- FROM TCard6000ת<EFBFBD>¿<EFBFBD> AS B,
-- TConsumeItemPayment AS A,
-- TConsumeBill AS T,
-- TMemberCardAccount AS C
-- WHERE T.FCardId = B.FCardId
-- AND A.FPayTypeId = B.FAcctId
-- AND T.FBillId = T.FBillId
-- AND C.FOldCardId = T.FCardId
-- AND C.FId = B.FId
---- UPDATE TConsumeBill SET FCardNo = '986803.1',FCardId = 8720287399098755275
---- WHERE FBillNo = '0111602280012'
----SELECT * FROM TMemberCard WHERE FCardNo = '986803.1'
--UPDATE A
-- SET A.FPayTypeId = 3,
-- A.FCardId = C.FNewCardId
-- FROM TCard6000ת<EFBFBD>¿<EFBFBD> AS B,
-- TConsumeItemPayment AS A,
-- TMemberCardAccount AS C
-- WHERE a.FCardId = B.FCardId
-- AND A.FPayTypeId = B.FAcctId
-- AND C.FOldCardId = a.FCardId
-- AND C.FId = B.FId
--UPDATE A
-- SET A.FPayTypeId = 3,
-- A.FCardId = C.FNewCardId
-- FROM TCard6000ת<EFBFBD>¿<EFBFBD> AS B,
-- TConsumeGoodsPayment AS A,
-- TConsumeBill AS T,
-- TMemberCardAccount AS C
-- WHERE T.FCardId = B.FCardId
-- AND A.FPayTypeId = B.FAcctId
-- AND T.FBillId = T.FBillId
-- AND C.FOldCardId = T.FCardId
-- AND C.FId = B.FId
----------------END
-----------------------------------------------------------------
--50000<EFBFBD><EFBFBD>
-----------------------------------------------------------------
SELECT * FROM TMemberCardType WHERE FNo = 'X'
SELECT * FROM TPayAccount WHERE FNo = 'F'
------------------------------------------------------------------
--<EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>ֱ<EFBFBD><EFBFBD>ת
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard50000ֱ<EFBFBD><EFBFBD>ת
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE FTypeId = dbo.FNCardTypeId('X')
AND A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND NOT EXISTS(SELECT 1 FROM TMemberCardAccount AS O WHERE O.FCardId = A.FCardId AND O.FAcctId = 3)
AND B.FAcctId = dbo.FNAcctId('F')
ORDER BY A.FCardNo
SELECT * FROM TCard50000ֱ<EFBFBD><EFBFBD>ת
--ת<EFBFBD>˻<EFBFBD>
UPDATE A
SET A.FAcctId = 3
FROM TCard50000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('F')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard50000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('F')
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard50000ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardOldAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('F')
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard50000ֱ<EFBFBD><EFBFBD>ת)
--<EFBFBD><EFBFBD>Щ<EFBFBD>˻<EFBFBD>ҪתΪ<EFBFBD>¿<EFBFBD>
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard50000ת<EFBFBD>¿<EFBFBD>
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND B.FAcctId = dbo.FNAcctId('F')
ORDER BY A.FCardNo
select * from TCard50000ת<EFBFBD>¿<EFBFBD>
--<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardTypeId = dbo.FNCardTypeId('x')
FROM TMemberCardAccount AS A
WHERE FId IN(SELECT FId FROM TCard50000ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardNo = B.FCardNo + '.X'
FROM TCard50000ת<EFBFBD>¿<EFBFBD> as b, TMemberCardAccount AS A
WHERE B.FId = A.FId
AND A.FAcctId = dbo.FNAcctId('F')
SELECT * FROM TMemberCardAccount WHERE FId IN(SELECT FId FROM TCard50000ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¿<EFBFBD>
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId
)
SELECT
FNewCardId AS FCardId,
FNewCardNo AS FCardNo,
FNewCardNo AS FFaceNo,
FNewCardTypeId AS FTypeId,
1,
FNewCardCompId AS FCompId,
FMemId AS FMemId,
FNewCardState AS FState,
FNewCardCreateDate AS FCreateDate,
FNewCardExpiredDate AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FNewCardCompId AS FSaleCompId,
0 AS FSaleBillId
FROM TMemberCardAccount
WHERE FId IN(SELECT FId FROM TCard50000ת<EFBFBD>¿<EFBFBD>)
UPDATE A
SET A.FAcctId = 3,
A.FCardId = A.FNewCardId
FROM TCard50000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('f')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard50000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('f')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard50000ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardOldAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('f')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard50000ת<EFBFBD>¿<EFBFBD>)
-----------------------------------------------------------------------------------
--End OF 50000
----------------------------------------------------------------------------------
SELECT * FROM TMemberCardACCOUNT WHERE FAcctId = dbo.FNAcctId('D')
SELECT * FROM TMemberCard WHERE FCardId = 4736404752336390445
-----------------------------------------------------------------
--<EFBFBD><EFBFBD>ë<EFBFBD><EFBFBD>
-----------------------------------------------------------------
SELECT * FROM TMemberCardType WHERE FNo = 'P'
SELECT * FROM TPayAccount WHERE FNo = 'E'
------------------------------------------------------------------
--<EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>ֱ<EFBFBD><EFBFBD>ת
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard<EFBFBD><EFBFBD>ëֱ<EFBFBD><EFBFBD>ת
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE FTypeId = dbo.FNCardTypeId('P')
AND A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND NOT EXISTS(SELECT 1 FROM TMemberCardAccount AS O WHERE O.FCardId = A.FCardId AND O.FAcctId = 3)
AND B.FAcctId = dbo.FNAcctId('E')
ORDER BY A.FCardNo
SELECT * FROM TCard<EFBFBD><EFBFBD>ëֱ<EFBFBD><EFBFBD>ת
--ת<EFBFBD>˻<EFBFBD>
UPDATE A
SET A.FAcctId = 3
FROM TCard<EFBFBD><EFBFBD>ëֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('E')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard<EFBFBD><EFBFBD>ëֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('E')
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard<EFBFBD><EFBFBD>ëֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardOldAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('E')
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard<EFBFBD><EFBFBD>ëֱ<EFBFBD><EFBFBD>ת)
--<EFBFBD><EFBFBD>Щ<EFBFBD>˻<EFBFBD>ҪתΪ<EFBFBD>¿<EFBFBD>
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard<EFBFBD><EFBFBD>ëת<EFBFBD>¿<EFBFBD>
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND B.FAcctId = dbo.FNAcctId('E')
ORDER BY A.FCardNo
select * from TCard<EFBFBD><EFBFBD>ëת<EFBFBD>¿<EFBFBD>
--<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardTypeId = dbo.FNCardTypeId('P')
FROM TMemberCardAccount AS A
WHERE FId IN(SELECT FId FROM TCard<EFBFBD><EFBFBD>ëת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardNo = B.FCardNo + '.P'
FROM TCard<EFBFBD><EFBFBD>ëת<EFBFBD>¿<EFBFBD> as b, TMemberCardAccount AS A
WHERE B.FId = A.FId
AND A.FAcctId = dbo.FNAcctId('E')
SELECT * FROM TMemberCardAccount WHERE FId IN(SELECT FId FROM TCard<EFBFBD><EFBFBD>ëת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¿<EFBFBD>
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId
)
SELECT
FNewCardId AS FCardId,
FNewCardNo AS FCardNo,
FNewCardNo AS FFaceNo,
FNewCardTypeId AS FTypeId,
1,
FNewCardCompId AS FCompId,
FMemId AS FMemId,
FNewCardState AS FState,
FNewCardCreateDate AS FCreateDate,
FNewCardExpiredDate AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FNewCardCompId AS FSaleCompId,
0 AS FSaleBillId
FROM TMemberCardAccount
WHERE FId IN(SELECT FId FROM TCard<EFBFBD><EFBFBD>ëת<EFBFBD>¿<EFBFBD>)
UPDATE A
SET A.FAcctId = 3,
A.FCardId = A.FNewCardId
FROM TCard<EFBFBD><EFBFBD>ëת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('E')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard<EFBFBD><EFBFBD>ëת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('E')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard<EFBFBD><EFBFBD>ëת<EFBFBD>¿<EFBFBD> AS B,TMemberCardOldAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('E')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard<EFBFBD><EFBFBD>ëת<EFBFBD>¿<EFBFBD>)
-----------------------------------------------------------------------------------
--End OF <EFBFBD><EFBFBD>ë
----------------------------------------------------------------------------------
-----------------------------------------------------------------
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
-----------------------------------------------------------------
SELECT * FROM TMemberCardType WHERE FNo = 'CSD'
SELECT * FROM TPayAccount WHERE FNo = 'DZ'
------------------------------------------------------------------
--<EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>ֱ<EFBFBD><EFBFBD>ת
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>ת
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE FTypeId = dbo.FNCardTypeId('CSD')
AND A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND NOT EXISTS(SELECT 1 FROM TMemberCardAccount AS O WHERE O.FCardId = A.FCardId AND O.FAcctId = 3)
AND B.FAcctId = dbo.FNAcctId('DZ')
ORDER BY A.FCardNo
SELECT * FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>ת
--ת<EFBFBD>˻<EFBFBD>
UPDATE A
SET A.FAcctId = 3
FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('DZ')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('DZ')
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardOldAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('DZ')
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>ת)
--<EFBFBD><EFBFBD>Щ<EFBFBD>˻<EFBFBD>ҪתΪ<EFBFBD>¿<EFBFBD>
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>¿<EFBFBD>
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND B.FAcctId = dbo.FNAcctId('DZ')
ORDER BY A.FCardNo
select * from TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>¿<EFBFBD>
--<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardTypeId = dbo.FNCardTypeId('CSD')
FROM TMemberCardAccount AS A
WHERE FId IN(SELECT FId FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardNo = B.FCardNo + '.CardTypeNo'
FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>¿<EFBFBD> as b, TMemberCardAccount AS A
WHERE B.FId = A.FId
AND A.FAcctId = dbo.FNAcctId('DZ')
SELECT * FROM TMemberCardAccount WHERE FId IN(SELECT FId FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¿<EFBFBD>
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId
)
SELECT
FNewCardId AS FCardId,
FNewCardNo AS FCardNo,
FNewCardNo AS FFaceNo,
FNewCardTypeId AS FTypeId,
1,
FNewCardCompId AS FCompId,
FMemId AS FMemId,
FNewCardState AS FState,
FNewCardCreateDate AS FCreateDate,
FNewCardExpiredDate AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FNewCardCompId AS FSaleCompId,
0 AS FSaleBillId
FROM TMemberCardAccount
WHERE FId IN(SELECT FId FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>¿<EFBFBD>)
UPDATE A
SET A.FAcctId = 3,
A.FCardId = A.FNewCardId
FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('DZ')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('DZ')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardOldAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('DZ')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>¿<EFBFBD>)
-----------------------------------------------------------------------------------
--End OF <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
----------------------------------------------------------------------------------
-----------------------------------------------------------------
--"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<EFBFBD><EFBFBD>
-----------------------------------------------------------------
SELECT * FROM TMemberCardType WHERE FNo = 'J'
SELECT * FROM TPayAccount WHERE FNo = 'C'
------------------------------------------------------------------
--<EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>ֱ<EFBFBD><EFBFBD>ת
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>ת
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE FTypeId = dbo.FNCardTypeId('J')
AND A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND NOT EXISTS(SELECT 1 FROM TMemberCardAccount AS O WHERE O.FCardId = A.FCardId AND O.FAcctId = 3)
AND B.FAcctId = dbo.FNAcctId('C')
ORDER BY A.FCardNo
SELECT * FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>ת
--ת<EFBFBD>˻<EFBFBD>
UPDATE A
SET A.FAcctId = 3
FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('C')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('C')
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardOldAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('C')
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>ת)
--<EFBFBD><EFBFBD>Щ<EFBFBD>˻<EFBFBD>ҪתΪ<EFBFBD>¿<EFBFBD>
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>¿<EFBFBD>
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND B.FAcctId = dbo.FNAcctId('C')
ORDER BY A.FCardNo
select * from TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>¿<EFBFBD>
--<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardTypeId = dbo.FNCardTypeId('J')
FROM TMemberCardAccount AS A
WHERE FId IN(SELECT FId FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardNo = B.FCardNo + '.J'
FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>¿<EFBFBD> as b, TMemberCardAccount AS A
WHERE B.FId = A.FId
AND A.FAcctId = dbo.FNAcctId('C')
SELECT * FROM TMemberCardAccount WHERE FId IN(SELECT FId FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¿<EFBFBD>
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId
)
SELECT
FNewCardId AS FCardId,
FNewCardNo AS FCardNo,
FNewCardNo AS FFaceNo,
FNewCardTypeId AS FTypeId,
1,
FNewCardCompId AS FCompId,
FMemId AS FMemId,
FNewCardState AS FState,
FNewCardCreateDate AS FCreateDate,
FNewCardExpiredDate AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FNewCardCompId AS FSaleCompId,
0 AS FSaleBillId
FROM TMemberCardAccount
WHERE FId IN(SELECT FId FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>¿<EFBFBD>)
UPDATE A
SET A.FAcctId = 3,
A.FCardId = A.FNewCardId
FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('C')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('C')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>¿<EFBFBD> AS B,TMemberCardOldAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('C')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>¿<EFBFBD>)
-----------------------------------------------------------------------------------
--End OF <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
----------------------------------------------------------------------------------
------------------------------------------------------------------
--<EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD>ֱ<EFBFBD><EFBFBD>ת
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard<EFBFBD><EFBFBD>ëֱ<EFBFBD><EFBFBD>ת
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE FTypeId = dbo.FNCardTypeId('OC')
AND A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND NOT EXISTS(SELECT 1 FROM TMemberCardAccount AS O WHERE O.FCardId = A.FCardId AND O.FAcctId = 3)
AND B.FAcctId = dbo.FNAcctId('D')
ORDER BY A.FCardNo
SELECT * FROM TCard<EFBFBD><EFBFBD>ëֱ<EFBFBD><EFBFBD>ת
--ת<EFBFBD>˻<EFBFBD>
UPDATE A
SET A.FAcctId = 3
FROM TCard<EFBFBD><EFBFBD>ëֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('D')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard<EFBFBD><EFBFBD>ëֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('D')
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3
FROM TCard<EFBFBD><EFBFBD>ëֱ<EFBFBD><EFBFBD>ת AS B,TMemberCardOldAcctHist AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('D')
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard<EFBFBD><EFBFBD>ëֱ<EFBFBD><EFBFBD>ת)
--<EFBFBD><EFBFBD>Щ<EFBFBD>˻<EFBFBD>ҪתΪ<EFBFBD>¿<EFBFBD>
SELECT B.FId,A.FCardId,A.FCardNo,B.FAcctId,P.FName,B.FBalance INTO TCard<EFBFBD><EFBFBD>ëת<EFBFBD>¿<EFBFBD>
FROM TMemberCard AS A,
TMemberCardAccount AS B,
TPayAccount AS P
WHERE A.FCardId = B.FCardId
AND B.FAcctId = P.FId
AND B.FAcctId != 3
AND B.FAcctId = dbo.FNAcctId('D')
ORDER BY A.FCardNo
select * from TCard<EFBFBD><EFBFBD>ëת<EFBFBD>¿<EFBFBD>
--<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardTypeId = dbo.FNCardTypeId('OC')
FROM TMemberCardAccount AS A
WHERE FId IN(SELECT FId FROM TCard<EFBFBD><EFBFBD>ëת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FNewCardNo = B.FCardNo + '.OC'
FROM TCard<EFBFBD><EFBFBD>ëת<EFBFBD>¿<EFBFBD> as b, TMemberCardAccount AS A
WHERE B.FId = A.FId
AND A.FAcctId = dbo.FNAcctId('D')
SELECT * FROM TMemberCardAccount WHERE FId IN(SELECT FId FROM TCard<EFBFBD><EFBFBD>ëת<EFBFBD>¿<EFBFBD>)
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¿<EFBFBD>
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId
)
SELECT
FNewCardId AS FCardId,
FNewCardNo AS FCardNo,
FNewCardNo AS FFaceNo,
FNewCardTypeId AS FTypeId,
1,
FNewCardCompId AS FCompId,
FMemId AS FMemId,
FNewCardState AS FState,
FNewCardCreateDate AS FCreateDate,
FNewCardExpiredDate AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FNewCardCompId AS FSaleCompId,
0 AS FSaleBillId
FROM TMemberCardAccount
WHERE FId IN(SELECT FId FROM TCard<EFBFBD><EFBFBD>ëת<EFBFBD>¿<EFBFBD>)
UPDATE A
SET A.FAcctId = 3,
A.FCardId = A.FNewCardId
FROM TCard<EFBFBD><EFBFBD>ëת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAccount AS A
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('D')
AND A.FId = B.FId
--<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard<EFBFBD><EFBFBD>ëת<EFBFBD>¿<EFBFBD> AS B,TMemberCardAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('D')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
--<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ
UPDATE A
SET A.FAcctId = 3,
A.FCardId = C.FNewCardId,
A.FCardTypeId = C.FNewCardTypeId
FROM TCard<EFBFBD><EFBFBD>ëת<EFBFBD>¿<EFBFBD> AS B,TMemberCardOldAcctHist AS A,TMemberCardAccount AS C
WHERE A.FCardId = B.FCardId
AND A.FAcctId = dbo.FNAcctId('D')
AND A.FCardId = C.FOldCardId
AND C.FId = B.FId
UPDATE TMemberCardAccount SET FOk = 1 WHERE FId IN(SELECT FId FROM TCard<EFBFBD><EFBFBD>ëת<EFBFBD>¿<EFBFBD>)
-----------------------------------------------------------------------------------
--End OF <EFBFBD><EFBFBD>ë
----------------------------------------------------------------------------------
SELECT * FROM TMemberCardAccount WHERE FAcctId NOT IN(3,5816181355469595633)
SELECT * FROM TPayAccount WHERE FId = 8766359884515282142
AND FCardId IN(SELECT FCardId FROM TMemberCard WHERE FState = 1)
SELECT * FROM TMemberCard WHERE FCardId = 7873590298966444083
UPDATE A SET A.FEnabled = B.FEnabled FROM TPayAccountSub AS A,TPayAccount AS B
WHERE A.FPayAccountId = B.FId
SELECT * FROM TPayAccountSub
/*
SELECT * FROM TConsumeItemPayment
SELECT * FROM TPayAccount WHERE FId = 5816181355469595633
SELECT * FROM TMemberCardAccount WHERE FAcctId = 3
UPDATE TMemberCardAccount SET FAcctId = 3 WHERE FAcctId = 6
UPDATE TMemberCardAcctHist SET FAcctId = 3 WHERE FAcctId = 6
UPDATE TMemberCardOldAcctHist SET FAcctId = 3 WHERE FAcctId = 6
SELECT * FROM TMemberCardAccount WHERE FAcctId = 7420045379273129994
SELECT * FROM TMemberCardOldAcctHist WHERE FAcctId = 7420045379273129994
SELECT * FROM TMemberCard WHERE FCardID = 7004306889657470830
SELECT * FROM TConsumeBill WHERE FCardTypeId = 5188146770730811392
SELECT * FROM TConsumeBill AS T,TConsumeItemPayment AS P
WHERE EXISTS(SELECT * from TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>ת AS A WHERE A.FCardId = T.FCardId AND P.FPayTypeId = A.FAcctId)
AND T.FBillId = P.FBillId
SELECT FId,FNo,FName INTO TPayAccountError FROM TPayAccount
WHERE 1=0
INSERT TPayAccountError
SELECT 44444 ,'44444' ,'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵĴ<EFBFBD>ֵ<EFBFBD>˻<EFBFBD>'
SELECT * FROM TCard1000ֱ<EFBFBD><EFBFBD>ת
SELECT * FROM TMemberCardOldAcctHist AS H
WHERE EXISTS(SELECT 1 FROM TMemberCardAccount AS A WHERE A.FCardID = H.FCardId)
AND H.FAcctId = 3
SELECT * FROM TMemberCardOldAcctHist AS H
--<EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD>ֵ<EFBFBD>˻<EFBFBD><EFBFBD>Dz<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD><EFBFBD><EFBFBD>
UPDATE H
SET H.FAcctId = 44444
SELECT *
FROM TMemberCardOldAcctHist AS H
WHERE NOT EXISTS(SELECT 1 FROM TMemberCardAccount AS A WHERE A.FCardID = H.FCardId AND A.FAcctId = H.FAcctId )
AND H.FAcctId = 3
AND H.FCardId = 5399231790984788126
SELECT * FROM TMemberCardOldAcctHist AS H
WHERE EXISTS(SELECT 1 FROM TCard<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>ת AS A WHERE A.FCardID = H.FCardId)
AND H.FAcctId = 3
AND H.FCardId = 5399231790984788126
SELECT * FROM TMemberCard WHERE FCardId = 4692986448666566486
UPDATE TMemberCardAccount
SET FCardTypeId = (SELECT FId FROM TMemberCardType WHERE FNo = 'D')
WHERE FAcctId = (SELECT FId FROM TPayAccount WHERE FNo = 'J')
*/
--ɾ<EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD>ʷ<EFBFBD>Ŀ<EFBFBD>
SELECT *--INTO TMemberCard_Deleted_OC
FROM TMemberCard AS C
WHERE NOT EXISTS(SELECT 1 FROM TMemberCardOldAcctHist AS D WHERE D.FCardId = C.FCardId)
AND NOT EXISTS(SELECT 1 FROM TMemberCardAccount AS E WHERE E.FCardId = C.FCardId AND E.FBalance > 0)
--AND FCardNo LIKE '%OC'
DELETE TMemberCardAccount WHERE FCardId IN(SELECT FCardId FROM TMemberCard_Deleted_OC)
DELETE TMemberCard WHERE FCardId IN(SELECT FCardId FROM TMemberCard_Deleted_OC)
UPDATE A
SET A.FMemo = B.FMemo
FROM TMember AS A,TMemberCard AS B
WHERE A.FMemId = B.FMemId
AND B.FMemo != ''
SELECT * FROM TMember
UPDATE TMemberCard SET FMemo = ''