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/木棉藤/导会员2.sql

294 lines
8.0 KiB

SELECT * FROM TImpMember3
SELECT * FROM TImpMember3 WHERE CUSTNO NOT IN (SELECT CUSTNO FROM TImpMember)
ALTER TABLE TImpMember3 ADD FMemId BIGINT
ALTER TABLE TImpMember3 ADD FCardNo VARCHAR(50)
ALTER TABLE TImpMember3 ADD FMemNo VARCHAR(50)
ALTER TABLE TImpMember3 ADD FName VARCHAR(50)
ALTER TABLE TImpMember3 ADD FGender INT
ALTER TABLE TImpMember3 ADD FMobile VARCHAR(50)
ALTER TABLE TImpMember3 ADD FCardTypeId BIGINT
ALTER TABLE TImpMember3 ADD FCourseId BIGINT
ALTER TABLE TImpMember3 ADD FBalance DECIMAL(18,6)
ALTER TABLE TImpMember3 ADD FRemainTimes INT
ALTER TABLE TImpMember3 ADD FPurTimes INT
ALTER TABLE TImpMember3 ADD FPurAmount DECIMAL(18,6)
ALTER TABLE TImpMember3 ADD FItemId BIGINT
ALTER TABLE TImpMember3 ADD FCreateDate DATETIME
ALTER TABLE TImpMember3 ADD FExpiredDate DATETIME
ALTER TABLE TImpMember3 ADD FCompId BIGINT
ALTER TABLE TImpMember3 ADD FCardId BIGINT
ALTER TABLE TImpMember3 ADD FMemo VARCHAR(1000)
ALTER TABLE TImpMember3 ADD FArrear DECIMAL(18,6)
ALTER TABLE TImpMember3 ADD FPoint DECIMAL(18,6)
ALTER TABLE TImpMember3 ADD FBirthday DATETIME
ALTER TABLE TImpMember3 ADD FBirthdayType CHAR
UPDATE TImpMember3 SET FMemId = dbo.FNNewId() WHERE FMemid IS NULL
UPDATE TImpMember3 SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL
UPDATE TImpMember3 SET FCardNo = CUSTNO
UPDATE TImpMember3 SET FMemNo = CUSTNO
UPDATE TImpMember3 SET FName = NAME
UPDATE TImpMember3 SET FMobile = CPhone
UPDATE TImpMember3 SET FGender = CASE WHEN SEX = '2' THEN 1 ELSE '0' END
UPDATE TImpMember3 SET FBalance = Amt
UPDATE TImpMember3 SET FCreateDate = LEFT(BDATE,4) + '-' + SUBSTRING(BDATE,5,2) + '-' + SUBSTRING(BDATE,7,2)
UPDATE TImpMember3 SET FExpiredDate = LEFT(EDATE,4) + '-' + SUBSTRING(EDATE,5,2) + '-' + SUBSTRING(EDATE,7,2)
UPDATE TImpMember3 SET FArrear = Ç·¿î
UPDATE TImpMember3 SET FMemo = ISNULL(REM,'') + '' + ISNULL(ACCREM,'')
UPDATE TImpMember3 SET FPoint = Ä¿Ç°»ý·Ö
SELECT * FROM TImpMember3
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,TImpMember3 AS B
WHERE A.¿Í»§±àºÅ =B.FCardNo
AND B.FCardNo = 'A020935'
UPDATE TImpTransLog SET FId = dbo.FNNewId(),
FTime = LEFT(ÈÕÆÚ,4) + '-' + SUBSTRING(ÈÕÆÚ,5,2) + '-' + RIGHT(ÈÕÆÚ,2),
FEmployee = Éè¼Æʦ+','+ÖúÀí,
FContentText = Ïû·ÑÏîÄ¿,
FAmount = ½ðî,
FCompId = (SELECT FId FROM TCompany WHERE FNo = '002')
SELECT * FROM TImpTransLog WHERE FMemId IS NULL
SELECT * FROM TImpMember3 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 TImpMember3)
SELECT * FROM TImpTransLog WHERE FMemId IS NULL
AND ¿Í»§±àºÅ = 'A020935'
UPDATE TCompany SET FAllowBooking = 1
WHERE FId > 1
SELECT * FROM TImpMember3
WHERE FMemNO = 'A020822'
SELECT * FROM TImpTransLog WHERE FMemId IS NULL
D
DELETE
UPDATE TImpMember3 SET BIRTHDAY = REPLACE(BIRTHDAY,' ','')
UPDATE TImpMember3 SET BIRTHDAY = '' WHERE BIRTHDAY IS NULL
UPDATE TImpMember3 SET BIRTHDAY = '9999' + BIRTHDAY WHERE LEN(BIRTHDAY) = 4
UPDATE TImpMember3 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 TImpMember3
WHERE LEN (BIRTHDAY) = 8
AND RIGHT(BIRTHDAY,4) != '0229'
AND RIGHT(BIRTHDAY,4) <= '1231'
SELECT * FROM TMemberCardType
UPDATE TImpMember3 SET FCardTypeId = 5494058162892437466
UPDATE TImpMember3 SET FCompId = (SELECT FID FROM TCompany WHERE FNo = '002')
SELECT * FROM TImpMember
SELECT BIRTHDAY
FROM TImpMember3
WHERE LEN (BIRTHDAY) = 8
AND RIGHT(BIRTHDAY,4) != '0229'
UPDATE TImpMember3 SET FBirthdayType = 'G'
UPDATE TImpMember3 SET FBirthdayType = 'L' WHERE ÉúÈÕ LIKE '%Å©Àú%'
UPDATE TImpMember3 SET FBirthday = REPLACE(REPLACE(ÉúÈÕ , 'Å©Àú','9999-') , 'ÑôÀú','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,
FName AS FName,
dbo.FNGetFirstPinYin(FName),
0 AS FTypeId,
FCompId AS FCompId,
ISNULL(FCreateDate ,'1900-01-01') AS FCreateDate,
FGender AS FGender,
'G' AS FBirthdayType,
FBirthday 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(FMemo,'') AS FMemo,
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
from TImpMember3
INSERT INTO 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,
(SELECT FValueType FROM TMemberCardType WHERE FId = FCardTypeId) AS FValueType,
FCompId AS FCompId,
FMemId AS FMemId,
1 AS FState,
ISNULL(FCreateDate,1900) AS FCreateDate,
FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FCompId AS FSaleCompId,
0 AS FSaleBillId,
'' AS FMemo
FROM TImpMember3
WHERE FCardTypeId IS NOT NULL
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
SELECT FMemId,dbo.FNNewId(),FCardId AS FCardId,3,FBalance,FBalance,0,FCreateDate,DATEADD(year,1, FCreateDate) AS FExpiredDate,''
FROM TImpMember3 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,A.FCompId,'DR','Import',0,'',A.FBalance,0,A.FBalance,0,getdate(),'´ÓExcelÖе¼Èë'
FROM TImpMember3 AS A
WHERE FCardTypeId IS NOT NULL
SELECT * FROM TImpTransLog WHERE ¿Í»§±àºÅ = 'A020935'
update A
SET A.FMemId
SELECT * FROM TMemberCard WHERE FId = 5494058162892437466
UPDATE A
SET A.FExpiredDate = B.FExpiredDate
FROM TMemberCard AS A,TImpMember3 AS B
WHERE A.FCardId = B.FCardId
SELECT * FROM TImpMember3
UPDATE A
SET A.FMemo = B.Rem
FROM TMemberCard AS A,TImpMember3 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,TImpMember3 AS B
WHERE A.FCardId = B.FCardId
UPDATE TImpMember3 SET FCardTypeId = CType + 1000
SELECT * FROM TMemberCard WHERE FMemo != ''
delete TImpMember3 where CUSTNO IN(SELECT CUSTNO FROM TImpMember2)