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

232 lines
7.0 KiB

1 year ago
INSERT ChongQing_XinChao..TMemberCardType(FId,FNo,FName,FValueType,FMaterial,FPrice,FAcctId,FDeposit,FAcctId2,FDeposit2,FAcctId3,FDeposit3,FTimes,FAlertBalance,FMinRchgAmt,FValidityPeriod,FValidityPeriodUnit,FAllowSale,FAllowRchg,FEnabled,FOrder,FSalePointMode,FSalePointValue,FRchgPointMode,FRchgPointValue)
SELECT CardTypeId = CardTypeId,
CardTypeId ='ST_' + cast(CardTypeId as varchar),
CardTypeName AS FName,
1 AS FValueType,
2 AS FMaterial,
0 AS FPrice,
3 AS FAcctId,
0 AS FDeposit,
0 as FAcctId2,
0 AS FDeposit2,
0 AS FAcctId3,
0 AS FDeposit3,
0 AS FTimes,
0 AS FAlertBalance,
0 AS FMinRchgAmt,
0 AS FValidityPeriod,
0 AS FValidityPeriodUnit,
0 AS FAllowSale,
0 AS FAllowRchg,
1,
1,
0 AS FSalePointMode,
0 AS FSalePointValue,
0 AS FRchgPointMode,
0 AS FRchgPointValue
FROM sh_cardType
ALTER TABLE sh_guest ADD FMemId BIGINT
ALTER TABLE sh_guest ADD FCardId BIGINT
UPDATE sh_guest SET FMemId = ChongQing_XinChao.dbo.FNNewId()
UPDATE sh_guest SET FCardId = ChongQing_XinChao.dbo.FNNewId()
DROP TABLE TImpMember
SELECT M.FMemId AS FMemId,
MIN(C.CardId) AS FMemNo,
M.FCardId AS FCardId,
M.guestName AS FName,
M.GuestMove AS FMobile,
M.GuestSex AS FGender,
B.SaveMoney AS FBalance,
M.RecordTime AS FCreateDate,
B.CardTypeId AS FCardTypeId
INTO TImpMember
FROM sh_guest AS M,sh_card AS C,sh_account AS B
WHERE M.guestId = C.PeopleId
AND B.guestId = M.GuestId
GROUP BY M.FMemId,M.FCardId,M.guestName, M.GuestMove, M.GuestSex,B.SaveMoney,M.RecordTime , B.CardTypeId
DROP TABLE TImpMember
SELECT FMemNo,SUM(1) FROM TImpMember GROUP BY FMemNo HAVING(SUM(1) > 1)
DELETE TImpMember WHERE FMemId = 7583462195287132536 AND FBalance = 0
SELECT * FROM TImpMember WHERE FMemId = 7583462195287132536
SELECT * FROM TImpMember WHERE FMemNo = '159'
UPDATE TImpMember SET FMemNo = 'ST' + FMemNo
SELECT * FROM sh_card WHERE sta = 1
SELECT * FROM sh_guest WHERE del = 1
SELECT * FROM sh_account WHERE sta = 1
WHERE cardid = '159'
SELECT * FROM sh_account WHERE = '159'
SELECT * FROM ChongQing_XinChao..TMemberCardAccount WHERE FMemId = 8874980485003166005
SELECT * FROM ChongQing_XinChao..TCompany
SELECT (FBalance) FROM TMemberCardAccount
WHERE FMemId IN(SELECT FMemId FROM TMember WHERE FCompId = 5429028285689905439)
AND FBalance <= 0
ORDER BY FBalance DESC
SELECT 25555.000000 / 1051
INSERT INTO ChongQing_XinChao.dbo.TMember(
FMemId,
FMemNo,
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 FMemId AS FId,
FMemNo AS FNo,
FName AS FName,
'' FBriefCode,
0 AS FTypeId,
5429028285689905439 AS FCompId,
FCreateDate AS FCreateDate,
FGender AS FGender,
'G' AS FBirthdayType,
NULL AS FBirthday,
'' AS FTelephone,
FMobile as FMobilePhone,
'' AS FQQ,
'' AS FWeChat,
'' AS FIdCard,
'' AS FEmail,
'' AS FAddress,
0 AS FProId,
'' AS FCPW,
'' AS FQPW,
0 AS FChargeEmpId,
0 AS FPoint,
1 AS FRecvConsSMS,
1 AS FRecvBulkSMS,
'' AS FMemo,
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
from TImpMember
WHERE FMemNo IN (SELECT FMemNo FROM ChongQing_XinChao.dbo.TMember)
WHERE FMemId IN (SELECT FMemId FROM ChongQing_XinChao.dbo.TMember)
UPDATE TImpMember SET FMemNo = '10013.SD' WHERE FMemId = '5456440979731825357'
SELECT * FROM TImpMember WHERE FMemNo = '10013.st'
INSERT INTO ChongQing_XinChao..TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId,
FMemo)
SELECT
FCardId AS FId,
FMemNo AS FNo,
FMemNo AS FFaceNo,
FCardTypeId AS FTypeId,
1,
5429028285689905439 AS FCompId,
FMemId AS FMemId,
1 AS FState,
FCreateDate AS FCreateDate,
dateadd(yy,100,FCreateDate) AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
0 AS FSaleCompId,
0 AS FSaleBillId,
'' AS FMemo
FROM TImpMember
INSERT ChongQing_XinChao..TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
SELECT FMemId,ChongQing_XinChao.dbo.FNNewId(),FCardId AS FCardId,5019881129281466329,FBalance,FBalance,0,FCreateDate,NULL,''
FROM TImpMember
INSERT ChongQing_XinChao..TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
select ChongQing_XinChao.dbo.FNNewId(), FMemId, FCardId,5019881129281466329,getdate(), FCardTypeId,5429028285689905439,'DR','Import',0,'', FBalance,0, FBalance,0,getdate(),'<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD>'
from TImpMember
SELECT
UPDATE ChongQing_XinChao..TMemberCardAccount
SET FAcctId = 5019881129281466329
WHERE FAcctId = 3
AND FMemId IN(SELECT FMemID FROM TImpMember)
UPDATE ChongQing_XinChao..TMemberCardAcctHist
SET FAcctId = 7462859093971055089
WHERE FAcctId = 3
AND FMemId IN(SELECT FMemID FROM TImpMember)
SELECT * FROM ChongQing_XinChao..TPAyAccount
SELECT * FROM sh_cardType
SELECT * FROM sh_guest
SELECT * FROM ChongQing_XinChao..TMemberCard
UPDATE ChongQing_XinChao.. TMemberCardType
SET FID = 1 + FId WHERE FId < 1000
SELECT * FROM ChongQing_XinChao.. TMemberCardType
UPDATE ChongQing_XinChao.. T SET FId = 0 WHERE FId = 1000
UPDATE ChongQing_XinChao.. TMemberCard SET FTypeId = 0 WHERE FTypeId = 1000
UPDATE ChongQing_XinChao.. TMemberCardType SET FAllowRchg = 1
UPDATE ChongQing_XinChao.. TMemberCardTypeSub
SET FCardTypeId = 1000 + FCardTypeId WHERE FCardTypeId < 1000
UPDATE ChongQing_XinChao.. TMemberCard
SET FTypeId = 1000 + FTypeId WHERE FTypeId < 1000
UPDATE ChongQing_XinChao.. TMemberCardAcctHist
SET FCardTypeId = 1000 + FCardTypeId WHERE FCardTypeId < 1000