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

46 lines
2.2 KiB

SELECT * FROM MMClient
WHERE FMember != ''
SELECT * FROM MMCard
WHERE FCardState = '使用'
SELECT CASE WHEN FClientName = '' THEN B.FCardNo ELSE FClientName END AS ,CASE WHEN FMt !='' THEN Fmt ELSE FTel END AS ,
CASE WHEN Fsex = '' THEN FSex ELSE '' END AS ,'公历' as ,'' as ,
'001' AS ,B.FCardNo as ,'A' + C.FCardTypeNo AS ,B.FBeginDate AS ,DATEADD(YEAR,100,B.FBeginDate) AS ,
b.fmoney AS ,0 as ,'' as ,A.FMember AS ,'' as ,0 ,0 as
FROM MMClient AS A,MMCard AS B,MMCardType AS C
WHERE A.FClientSN = B.FClientSN
AND B.FCardState = '使用'
AND B.FCardTypeSN = C.FCardTypeSn
SELECT * FROM MMCardType
SELECT
INSERT INTO qingdao_xiangzuo.dbo.TMemberCardType(FId,FNo,FName,FValueType,FMaterial,FPrice,FCardFeeAmt,FAcctId,FDeposit,FAcctId2,FDeposit2,FAcctId3,FDeposit3,FTimes,FAlertBalance,FMinRchgAmt,FSalePointMode,FSalePointValue,FRchgPointMode,FRchgPointValue,FPaySmsFee,FTimeCard,FValidityPeriod,FValidityPeriodUnit,FExpiredDate,FDefaultMemo,FCreateTime,FAllowSale,FAllowRchg,FDeptId,FEnabled,FOrder)
SELECT FId = qingdao_xiangzuo.dbo.FNNewId(), 'A' + FCardTypeNo,FCardType,1,FMaterial = 2,FSNPrc,FCardFeeAmt = 0,FAcctId = 3,FDeposit = FInitMoney,FAcctId2 = 0,FDeposit2 = 0 ,FAcctId3 = 0,FDeposit3 = 0,
FTimes = 0,FAlertBalance = 0,FMinRchgAmt = 0,FSalePointMode = 0,FSalePointValue = 0 ,FRchgPointMode = 0,FRchgPointValue = 0,FPaySmsFee = 0,FTimeCard = 0,FValidityPeriod = 100,FValidityPeriodUnit = 1,
FExpiredDate = NULL,FDefaultMemo = '',FCreateTime = GETDATE(),1,1,FDeptId = 0,FEnabled =1,FOrder = 1
FROM MMCardType
UPDATE MMCardType SET FCardTypeNo = 'A' + FCardTypeNo
ALTER TABLE MMCardType ALTER COLUMN FCardTypeNo VARCHAR(10)
SELECT FCardTypeNo FROM MMCardType
GROUP BY FCardTypeNo
HAVING SUM(1) > 1
INSERT INTO TMemberCardTypeSub(FId,FCompId,FCardTypeId,FAllowSale,FAllowRchg,FEnabled)
SELECT dbo.FNNewId(),C.FId,I.FId,FAllowSale,FAllowRchg,FEnabled
FROM TMemberCardType AS I,TCompany AS C
WHERE I.FId > 1
AND C.FId != 0
AND C.FNo IN( '003','000','002')
AND NOT EXISTS(SELECT TOP 1 1 FROM TMemberCardTypeSub AS B WHERE B.FCompId = C.FId AND B.FCardTypeId = I.FId)