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

356 lines
10 KiB

SELECT * FROM TImpMember
SELECT * FROM TImpMember
WHERE CUSTNO NOT IN (SELECT CUSTNO FROM TImpMember)
INSERT INTO TMemberCardType(FId,FNo,FName,FValueType,FMaterial,FPrice,FCardFeeAmt,FAcctId,FDeposit,FAcctId2,FDeposit2,
FAcctId3,FDeposit3,FTimes,FAlertBalance,FPaySmsFee,FTimeCard,FValidityPeriod,FValidityPeriodUnit,FExpiredDate,
FDefaultMemo,FCreateTime,FAllowSale,FAllowRchg,FEnabled,FOrder,FDeptId)
SELECT dbo.FNNewId() AS FId,FCardTypeName AS FNo,FCardTypeName AS FName,1 AS ValueType,1 AS FMaterial,0 AS FPrice,0 AS FCardFeeAmt,0 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 FPaySmsFee,0 AS FTimeCard,0 AS FValidityPeriod,0 AS FValidityPeriodUnit,'' AS FExpiredDate,'' AS FDefaultMemo,'' AS FCreateTime,0 AS FAllowSale,0 AS FAllowRchg,1 AS FEnabled,0 AS FOrder,0 AS FDeptId
FROM TImpMember
GROUP BY FCardTypeName
SELECT * FROM TMemberCardType
UPDATE TMemberCardType SET FSalePointValue = 0,FRchgPointValue = 0 ,FAllowSale=1,FAllowRchg = 1,FMaterial = 2
ALTER TABLE TImpMember ADD FMemId BIGINT
ALTER TABLE TImpMember ADD FCardNo VARCHAR(50)
ALTER TABLE TImpMember ADD FMemNo VARCHAR(50)
ALTER TABLE TImpMember ADD FName VARCHAR(50)
ALTER TABLE TImpMember ADD FGender INT
ALTER TABLE TImpMember ADD FMobile VARCHAR(50)
ALTER TABLE TImpMember ADD FCardTypeId BIGINT
ALTER TABLE TImpMember ADD FCourseId BIGINT
ALTER TABLE TImpMember ADD FDeposit DECIMAL(18,6)
ALTER TABLE TImpMember ADD FBalance DECIMAL(18,6)
ALTER TABLE TImpMember ADD FRemainTimes INT
ALTER TABLE TImpMember ADD FPurTimes INT
ALTER TABLE TImpMember ADD FPurAmount DECIMAL(18,6)
ALTER TABLE TImpMember ADD FItemId BIGINT
ALTER TABLE TImpMember ADD FCreateDate DATETIME
ALTER TABLE TImpMember ADD FExpiredDate DATETIME
ALTER TABLE TImpMember ADD FCompId BIGINT
ALTER TABLE TImpMember ADD FCardId BIGINT
ALTER TABLE TImpMember ADD FMemo VARCHAR(1000)
ALTER TABLE TImpMember ADD FArrear DECIMAL(18,6)
ALTER TABLE TImpMember ADD FPoint DECIMAL(18,6)
ALTER TABLE TImpMember ADD FBirthday DATETIME
ALTER TABLE TImpMember ADD FBirthdayType CHAR
ALTER TABLE TImpMember ADD FTotalTimes INT
ALTER TABLE TImpMember ADD FUsedTimes INT
ALTER TABLE TImpMember ADD FDeleted BIT
ALTER TABLE TImpMember ADD FState INT
UPDATE TImpMember SET FMemId = dbo.FNNewId() WHERE FMemid IS NULL
UPDATE TImpMember SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL
UPDATE TImpMember SET FMemNo = FCardNo
UPDATE TImpMember SET FMemo = ISNULL(F2,'')+ ',' + ISNULL(F6,'') + ',<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:[' + ISNULL(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,'') + '], ' + ISNULL(F4,'') + ',' + '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:' + ISNULL(F15 ,'')+ ',' + ISNULL(F16,'') + ',' + ISNULL(F17,'') + ',' + ISNULL(F18 ,'')+ ',' + ISNULL(F19 ,'')+ ',' + ISNULL(F20 ,'')+ ',' + ISNULL(F21 ,'')
UPDATE TImpMember SET FDeposit = <EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FBalance = FDeposit - <EFBFBD><EFBFBD><EFBFBD>ѽ<EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FCardTypeId = B.FId
FROM TImpMember AS A,TMemberCardType AS B
WHERE A.FCardTypename = B.FName
UPDATE TImpMember SET FDeleted = 0
UPDATE TImpMember SET FState = 1
UPDATE TImpMember SET FDeleted = 1
WHERE FStateName = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE TImpMember SET FState = 5
WHERE FStateName = '<EFBFBD><EFBFBD>ʧ'
SELECT * FROM TImpMember AS A
WHERE FStateName != '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
AND FStateName != '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
DELETE TImpMember WHERE FMemNo is null AND FMobile IS NULL AND FName IS NULL
UPDATE TImpMember SET FMemNo = FMobile WHERE FMemNo IS NULL
UPDATE TImpMember SET FMemNo = FName WHERE FMemNo IS NULL
UPDATE TImpMember SET FMemNo = FMobile WHERE FMemNo = '<EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD>'
UPDATE TImpMember SET FMemNo = FMemNo + '.' + FMobile WHERE FMemNo = '600004'
DELETE TImpMember WHERE FMemNO = '801291'
DELETE TImpMember WHERE FMemNO = '600151'
DELETE TImpMember WHERE FMemNO = '15898883444' AND <EFBFBD><EFBFBD><EFBFBD><EFBFBD> IS NULL
SELECT * FROM TMemberCardType
UPDATE T
SELECT FMemNo ,SUM(1)
FROM TImpMember
GROUP BY FMemNO ORDER BY SUM(1) DESC
UPDATE TImpMember SET FGender = 0
UPDATE TImpMember SET FExpiredDate = DATEADD(YEAR,100,FCreateDate)
SELECT * FROM TImpMember
PClearMemberData
SELECT * FROM TConsumeBill
SELECT * FROM TMemberCardAccount
SELECT * FROM TImpTransLog
ALTER TABLE TImpTransLog ADD
FMemId BIGINT,
FId BIGINT,
FTime DATETIME,
FCompId BIGINT,
FEmployee VARCHAR(1000),
FContentText VARCHAR(1000)
ALTER TABLE TImpTransLog ADD FAmount DECIMAL(18,6)
ALTER TABLE TImpTransLog ADD FCardId BIGINT
UPDATE A
SET A.FMemId = B.FMemId,
A.FCardId = B.FCardId
FROM TImpTransLog AS A,TImpMember AS B
WHERE A.<EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> =B.FCardNo
AND B.FCardNo = 'A020935'
UPDATE TImpTransLog SET FId = dbo.FNNewId(),
FTime = LEFT(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,4) + '-' + SUBSTRING(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,5,2) + '-' + RIGHT(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,2),
FEmployee = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʦ+','+<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
FContentText = <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ,
FAmount = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
FCompId = (SELECT FId FROM TCompany WHERE FNo = '002')
SELECT * FROM TImpTransLog WHERE FMemId IS NULL
SELECT * FROM TImpMember WHERE FMemNo = 'A020935'
INSERT TMemberOldTransHist(FId,FCompId,FMemId,FTime,FCardId,FBIllType,FBizType,FTransNo,FCOntent,FPrice,FQuantity,FAmount,FPayment,Femployee,FMemo)
SELECT FId,FCompId,FMemId,ISNULL(FTime,'1753-01-01'),FCardId,'','',ISNULL('','') AS FTransNo,
ISNULL(FContentText,''),FAmount,1,FAmount,ISNULL('',''),'', '' AS FMemo
FROM TImpTransLog
WHERE FMemId IS NOT NULL
AND FMemId IN(SELECT FMemId FROM TImpMember)
SELECT * FROM TImpTransLog WHERE FMemId IS NULL
AND <EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = 'A020935'
UPDATE TCompany SET FAllowBooking = 1
WHERE FId > 1
SELECT * FROM TImpMember
WHERE FMemNO = 'A020822'
SELECT * FROM TImpTransLog WHERE FMemId IS NULL
D
DELETE
UPDATE TImpMember SET BIRTHDAY = REPLACE(BIRTHDAY,' ','')
UPDATE TImpMember SET BIRTHDAY = '' WHERE BIRTHDAY IS NULL
UPDATE TImpMember SET BIRTHDAY = '9999' + BIRTHDAY WHERE LEN(BIRTHDAY) = 4
UPDATE TImpMember SET FBirthday = LEFT(BIRTHDAY,4) + '-' + SUBSTRING(BIRTHDAY,5,2) + '-' + SUBSTRING(BIRTHDAY,7,2)
WHERE LEN (BIRTHDAY) = 8
AND RIGHT(BIRTHDAY,4) != '0229'
AND RIGHT(BIRTHDAY,4) != '0229'
AND RIGHT(BIRTHDAY,4) <= '1231'
SELECT CAST( LEFT(BIRTHDAY,4) + '-' + SUBSTRING(BIRTHDAY,5,2) + '-' + SUBSTRING(BIRTHDAY,7,2) AS DATETIME)
FROM TImpMember
WHERE LEN (BIRTHDAY) = 8
AND RIGHT(BIRTHDAY,4) != '0229'
AND RIGHT(BIRTHDAY,4) <= '1231'
SELECT * FROM TMemberCardType
UPDATE TImpMember SET FCardTypeId = 5494058162892437466
UPDATE TImpMember SET FCompId = (SELECT FID FROM TCompany WHERE FNo = '002')
SELECT * FROM TImpMember
SELECT BIRTHDAY
FROM TImpMember
WHERE LEN (BIRTHDAY) = 8
AND RIGHT(BIRTHDAY,4) != '0229'
UPDATE TImpMember SET FBirthdayType = 'G'
UPDATE TImpMember SET FBirthdayType = 'L' WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE '<EFBFBD><EFBFBD>%'
UPDATE TImpMember SET FBirthday = REPLACE(REPLACE(<EFBFBD><EFBFBD><EFBFBD><EFBFBD> , 'ũ<EFBFBD><EFBFBD>','9999-') , '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>','9999-')
INSERT INTO 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 FMemId,
FMemNo AS FMemNo,
ISNULL(ISNULL(FName,FMobile),FMemNo) AS FName,
dbo.FNGetFirstPinYin(FName),
0 AS FTypeId,
1 AS FCompId,
getdate() AS FCreateDate,
0 AS FGender,
'G' AS FBirthdayType,
NULL AS FBirthday,
'' AS FTelephone,
ISNULL(FMobile,'') AS FMobilePhone,
'' AS FQQ,
'' AS FWeChat,
'' AS FIdCard,
'' AS FEmail,
'' AS FAddress,
0 AS FProId,
'' AS FCPW,
'' AS FQPW,
0 AS FChargeEmpId,
ISNULL( FPoint,0) AS FPoint,
1 AS FRecvConsSMS,
1 AS FRecvBulkSMS,
ISNULL('','') AS FMemo,
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
from TImpMember
UPDATE A
SET A.FDeleted = B.FDeleted
FROM TMember AS A,TImpMember AS B
WHERE A.FMemId = B.FMemId
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId,
FMemo,FDeleted)
SELECT
FCardId AS FId,
FMemNo AS FNo,
FMemno AS FFaceNo,
FCardTypeId AS FTypeId,
(SELECT FValueType FROM TMemberCardType WHERE FId = FCardTypeId) AS FValueType,
1 AS FCompId,
FMemId AS FMemId,
FState AS FState,
getdate() AS FCreateDate,
'9999-01-01',
0 AS FTotalTimes,
0 AS FUsedTimes,
1 AS FSaleCompId,
0 AS FSaleBillId,
'' AS FMemo,FDeleted
FROM TImpMember
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
SELECT FMemId,dbo.FNNewId(),FCardId AS FCardId,3,FBalance,FBalance,0,FCreateDate,NULL AS FExpiredDate,''
FROM TImpMember AS A
WHERE FCardTypeId IS NOT NULL
INSERT 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,3,getdate(),A.FCardTypeId,1,'DR','Import',0,'',A.FBalance,0,A.FBalance,0,getdate(),'<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>'
FROM TImpMember AS A
SELECT * FROM TImpTransLog WHERE <EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = 'A020935'
update A
SET A.FMemId
SELECT * FROM TMemberCard WHERE FId = 5494058162892437466
UPDATE A
SET A.FExpiredDate = B.FExpiredDate
FROM TMemberCard AS A,TImpMember AS B
WHERE A.FCardId = B.FCardId
SELECT * FROM TImpMember
UPDATE A
SET A.FMemo = B.Rem
FROM TMemberCard AS A,TImpMember AS B
WHERE A.FCardId = B.FCardId
AND B.Rem IS NOT NULL
SELECT * FROM TMemberCardType
UPDATE TMemberCardType SET FId = FNo + 1000 WHERE FId > 0
UPDATE TMemberCard SET FTypeId = 0
DELETE TMemberCardTypeSUB
UPDATE A
SET A.FTypeId = B.CType + 1000
FROM TMemberCard AS A,TImpMember AS B
WHERE A.FCardId = B.FCardId
UPDATE TImpMember SET FCardTypeId = CType + 1000
SELECT * FROM TMemberCard WHERE FMemo != ''
delete TImpMember where CUSTNO IN(SELECT CUSTNO FROM TImpMember2)