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

731 lines
23 KiB

1 year ago
use qingdao_oufan
SELECT * FROM gdm01
SELECT * FROM TimpMember WHERE FCPW != ''
SELECT * FROM TImpMemberTransHist
SELECT * FROM TImpMemberCourse
SELECT * FROM TImpMemberCardAccthist
DELETE TImpMemberTransHist
DELETE FROM TImpMemberCourse
DELETE FROM TImpMemberCardAccthist
SELECT * FROM TImpMember where <EFBFBD><EFBFBD><EFBFBD><EFBFBD> < '532101429'
select
DELETE TImpMember
SELECT * FROM TImpMemberCourse
SELECT * FROM TImpMember
WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> != '<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD>'
SELECT * FROM TImpMemberCourse WHERE <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>= '<EFBFBD>ƿ<EFBFBD>Ӫ<EFBFBD><EFBFBD>'
CREATE TABLE TImpCardType
(
FCardTypeName VARCHAR(500),
FCardTypeNo VARCHAR(50),
FCardTypeId BIGINT
)
INSERT TImpCardType(FCardTypeName,FCardTypeNo,FCardTypeId)
SELECT <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,DBO.FNNewId()
from TImpMemberCourse
WHERE <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>= '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
group by <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
INSERT INTO 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 =FCardTypeId, FCardTypeNo,FCardTypeName,1,FMaterial = 2,0,FCardFeeAmt = 0,FAcctId = 3,FDeposit = 0,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 TImpCardType
--<EFBFBD><EFBFBD>Ա
ALTER TABLE TImpMemberInfo ADD FMemId BIGINT
ALTER TABLE TImpMemberInfo ADD FCardTypeName VARCHAR(100)
ALTER TABLE TImpMemberInfo ADD FMemNo VARCHAR(50)
ALTER TABLE TImpMemberInfo ADD FName VARCHAR(50)
ALTER TABLE TImpMemberInfo ADD FGender INT
ALTER TABLE TImpMemberInfo ADD FMobile VARCHAR(50)
ALTER TABLE TImpMemberInfo ADD FBirthdayType VARCHAR(50)
ALTER TABLE TImpMemberInfo ADD FBirthday DATETIME
ALTER TABLE TImpMemberInfo ADD FCompId BIGINT
ALTER TABLE TImpMemberInfo ADD FCreateDate DATETIME
ALTER TABLE TImpMemberInfo ADD FMemo VARCHAR(MAX)
SELECT * FROM TImpMemberInfo
UPDATE TImpMemberInfo
SET FMemId = abs( CAST( CAST(cast(memid as uniqueidentifier) AS BINARY(8)) AS BIGINT))
UPDATE A
SET A.FMemNo = B.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
FROM TImpMemberInfo AS A,TImpMember AS B
WHERE A.<EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = B.<EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMemberInfo SET FMemNo = <EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> WHERE FMemNo IS NULL
UPDATE A
SET A.FCreateDate = (SELECT MIN(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>) FROM TImpMember AS B WHERE A.<EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = B.<EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
FROM TImpMemberInfo AS A
UPDATE TImpMemberInfo SET FCreateDate ='1900-01-01'
WHERE FCreateDate IS NULL
UPDATE TImpMemberInfo SET FName = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMemberInfo SET FMobile = <EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMemberInfo SET FGender = CASE WHEN <EFBFBD>Ա<EFBFBD> = '<EFBFBD><EFBFBD>' THEN '1' ELSE 0 END
UPDATE TImpMemberInfo SET FGender = CASE WHEN <EFBFBD>Ա<EFBFBD> = '<EFBFBD><EFBFBD>' THEN '1' ELSE 0 END
UPDATE TImpMemberInfo SET FBirthdayType = 'G'
UPDATE TImpMemberInfo SET FBirthdayType = 'L' WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE '<EFBFBD><EFBFBD>%'
UPDATE TImpMemberInfo SET FBirthday = REPLACE(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,'<EFBFBD><EFBFBD><EFBFBD><EFBFBD>','')
UPDATE TImpMemberInfo SET FCompId = 1
SELECT * FROM TMember
SELECT FMemId,sum(1)
FROM TImpMemberInfo
GROUP BY FMemId
ORDER BY sum(1) DESC
SELECT * FROM TImpMemberInfo
where <EFBFBD>ֿ<EFBFBD><EFBFBD><EFBFBD> > 1
SELECT * FROM TImpMemberInfo
where <EFBFBD><EFBFBD>Ƭ is null
DELETE TImpMemberInfo
SELECT <EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ,sum(1)
from TImpMemberInfo
GROUP BY <EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ORDER BY SUM(1) DESC
SELECT COUNT(1)FROM TImpMember
WHERE <EFBFBD><EFBFBD>ע IS NULL
UPDATE A SET FMemo = B.<EFBFBD><EFBFBD>ע
FROM TImpMember AS B,TImpMemberInfo AS A
WHERE <EFBFBD><EFBFBD>ע!= ''
AND A.<EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = B.<EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FMemo = B.FMemo
FROM TImpMemberInfo AS B,TMember AS A
WHERE A.FMemId = B.FMemId
AND ISNULL(B.FMemo,'') != ''
--<EFBFBD><EFBFBD>
ALTER TABLE TImpMember ADD FMemId BIGINT
ALTER TABLE TImpMember ADD FCardTypeName VARCHAR(100)
ALTER TABLE TImpMember ADD FCardNo VARCHAR(50)
ALTER TABLE TImpMemberCourse ADD FCardState INT
ALTER TABLE TImpMemberCourse ADD FMemId BIGINT
ALTER TABLE TImpMemberCourse ADD FCardTypeId BIGINT
ALTER TABLE TImpMemberCourse ADD FIsCourse BIT
ALTER TABLE TImpMemberCourse ADD FCalcMode INT
ALTER TABLE TImpMemberCourse ADD FBalance DECIMAL(18,6)
ALTER TABLE TImpMemberCourse ADD FRemainTimes INT
ALTER TABLE TImpMemberCourse ADD FPurTimes INT
ALTER TABLE TImpMemberCourse ADD FPurAmount DECIMAL(18,6)
ALTER TABLE TImpMemberCourse ADD FItemId BIGINT
ALTER TABLE TImpMemberCourse ADD FCreateDate DATETIME
ALTER TABLE TImpMemberCourse ADD FExpiredDate DATETIME
ALTER TABLE TImpMemberCourse ADD FCompId BIGINT
ALTER TABLE TImpMemberCourse ADD FCardId BIGINT
ALTER TABLE TImpMemberCourse ADD FMemo VARCHAR(1000)
ALTER TABLE TImpMemberCourse ADD FArrear DECIMAL(18,6)
ALTER TABLE TImpMemberCourse ADD FPoint DECIMAL(18,6)
ALTER TABLE TImpMemberCourse ADD FState INT
ALTER TABLE TImpMemberCourse ADD FCardNo VARCHAR(1000)
SELECT * FROM TImpMember WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD> NOT IN(SELECT FCardNo FROM TImpMemberCourse)
--<EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD>
UPDATE TImpMemberCourse
SET FCardId = abs( CAST( CAST(cast(CardId as uniqueidentifier) AS BINARY(8)) AS BIGINT))
SELECT * FROM TImpMemberCourse WHERE CardId = '8e07e178-11b0-41eb-84a5-a51600d0c6b6'
SELECT CardId,SUM(1)
FROM TImpMemberCourse
GROUP BY CardId
ORDER BY SUM(1) DESC
UPDATE TImpMemberCourse SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL
UPDATE TImpMemberCourse SET FCompId = 1
SELECT * FROM TImpMemberCourse WHERE <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> != '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE TImpMemberCourse SET FIsCourse = 0
UPDATE TImpMemberCourse SET FIsCourse = 1 WHERE <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> != '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE TImpMemberCourse SET FCalcMode = 1 WHERE <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƴ<EFBFBD>'
UPDATE TImpMemberCourse SET FCalcMode = 2 WHERE <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = '<EFBFBD><EFBFBD><EFBFBD>޴<EFBFBD><EFBFBD><EFBFBD>'
UPDATE TImpMemberCourse SET FCalcMode = 1 WHERE <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƴ<EFBFBD>'
SELECT * FROM TCourse WHERE FName = '<EFBFBD>ƿ<EFBFBD>Ӫ<EFBFBD><EFBFBD>'
UPDATE TImpMemberCourse SET FCalcMode = 1 WHERE <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE '%<EFBFBD><EFBFBD>%'
UPDATE TImpMemberCourse SET FIsCOurse = 1 WHERE <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE '%<EFBFBD><EFBFBD>%'
UPDATE TImpMemberCourse SET FRemainTimes = CAST(ʣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT) WHERE <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE '%<EFBFBD><EFBFBD>%'
UPDATE TImpMemberCourse SET FBalance = 0 WHERE <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE '%<EFBFBD><EFBFBD>%'
SELECT * FROM TImpMemberCourse WHERE <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE '%<EFBFBD><EFBFBD>%'
UPDATE A SET A.FCreateDate = B.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>,
A.FExpiredDate = A.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
FROM TImpMemberCourse AS A,TImpMEMBER AS B
WHERE A.CardId = B.CardId
SELECT ״̬ FROM TImpMemberCourse
GROUP BY ״̬
UPDATE TImpMemberCourse SET FState = 1 WHERE ״̬ != '<EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>'
UPDATE TImpMemberCourse SET FState = 2 WHERE ״̬ = '<EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>'
UPDATE A
SET A.FName = B.FName
FROM TCourse AS A,TItem AS B
WHERE A.FItemId = B.FId
AND B.FNo IN(SELECT <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FROM TImpMemberCourse)
UPDATE A
SET A.FCalcMode = B.FCalcMode
FROM TCourse AS A,TImpMemberCourse AS B,TItem AS I
WHERE I.FNo = B.<EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
AND I.FId = A.FItemId
AND B.FIsCourse = 1
--AND <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE '%<EFBFBD><EFBFBD>%'
SELECT * FROM TImpMemberCourse WHERE FIsCourse = 1
AND FCalcMode = 0
UPDATE A
SET A.FMemId = M.FMemId
FROM TImpMemberCourse AS A,TImpMember AS B,TImpMemberInfo AS M
WHERE M.<EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = B.<EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
AND A.CardId = B.CardId
UPDATE A
SET A.FCardTypeId = B.FId,
A.FItemId = B.FItemId
FROM TImpMemberCourse AS A,TCourse AS B,TItem AS I
WHERE A.<EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>= I.FNo
AND A.FCalcMode = B.FCalcMode
AND I.FId = B.FItemId
-- AND <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE '%<EFBFBD><EFBFBD>%'
SELECT * FROM TImpMemberCourse WHERE FCardTypeId IS NULL AND FIsCourse = 1
UPDATE TImpMemberCourse SET FRemainTimes = CAST(ʣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT)
UPDATE TImpMemberCourse SET FBalance = CAST(ʣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT)
SELECT * FROM TImpMemberCourse WHERE FIsCourse = 1
SELECT * FROM TCourse WHERE FCalcMode = 2
SELECT * FROM TMemberCardType
SELECT * FROM TImpMember
WHERE CAST(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT) != 0
SELECT A.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,A.<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,A.<EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,A.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>, B.<EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,B.<EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,B.ʣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,B.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>, CAST(A.<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT)
FROM TImpMember AS A,TImpMemberCourse AS B
WHERE a.<EFBFBD><EFBFBD><EFBFBD><EFBFBD> = B.FCardNo
AND CAST(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT) != 0
SELECT * FROM TImpMemberCourse WHERE FCardNo = '532108609'
SELECT * FROM TImpMember WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD> = '532108609'
UPDATE TImpMember
SET FCardID = abs( CAST( CAST(cast(CardId as uniqueidentifier) AS BINARY(8)) AS BIGINT))
SELECT FCardID,sum(1)
FROM TImpMember
GROUP BY FCardID
ORDER BY sum(1) DESC
SELECT * FROM TConsumeBill
DELETE TImpMemberCourseEx
sp_rename 'TImpMemberCourse','TImpMemberCourse_Old'
sp_rename 'TImpMemberCourseEx','TImpMemberCourse'
SELECT count(1) FROM TImpMemberCourseEx
SELECT * FROM TImpMemberCourse
SELECT * FROM TImpMemberCourse
SELECT * FROM TMemberCourseLog
WHERE FBillType != 'DR'
sp_rename 'TImpMemberCourse','TImpMemberCourseEx'
SELECT * FROM TConsumeBill
DELETE TMemberCardAcctHist
DELETE TMemberCard WHERE FCardId> 0
DELETE TMemberCourseLog
SELECT * FROM TMemberSaleBill
ALTER TABLE TImpMemberCourseEx ALTER COLUMN <EFBFBD><EFBFBD><EFBFBD><EFBFBD> VARCHAR(2000)
SELECT * FROM TMemberPhoto
INSERT TMemberPhoto(FMemId,FType,FImage,FImagePath)
SELECT FMemId,1,NULL,<EFBFBD><EFBFBD>Ƭ
FROM TImpMemberInfo
WHERE <EFBFBD><EFBFBD>Ƭ != ''
SELECT * FROM TMemberPhoto
SELECT * FROM TImpMember WHERE CardId IS NULL
SELECT * FROM TImpMemberInfo WHERE MemId IS NULL
SELECT * FROM TImpMemberCourse
SELECT * FROM TImpMemberInfo WHERE FName like '%<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%'
SELECT * FROM TImpMember WHERE <EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = '13608978208'
SELECT * FROM TImpMemberCourse WHERE FCardNo = '532102891'
SELECT * FROM TImpMember WHERE CardId = '43fdd01c-8919-451d-8087-a5e400b339a6'
UPDATE A
SET A.FMobilePhone = B.<EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
FROM TMember AS A,TImpMemberInfo AS B
WHERE A.FMemId = B.FMemId
UPDATE A
SET A.FMemId = B.FMemId
FROM TImpMemberCourse AS A,TImpMember AS C,TImpMemberInfo AS B
WHERE A.FCardNO = C.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
AND C.<EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>= B.<EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID
UPDATE TImpMemberInfo SET MemId = REPLACE(LEFT(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,CHARINDEX(',',<EFBFBD><EFBFBD><EFBFBD><EFBFBD>)-1),'/MemberInfo/Delete/','')
FROM TImpMemberInfo
SELECT * FROM TMember WHERE FMemNo = '532101341'
UPDATE TMemberCourse SET FExpiredDate = nULL WHERE FExpiredDate = '1900-01-01 00:00:00.000' AND FCalcMode = 1
--ɾ<EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD><EFBFBD><EFBFBD>
DELETE TMemberCardAccount WHERE FCardId IN(SELECT FCardId FROM TImpMemberCourse WHERE <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE '%<EFBFBD><EFBFBD>%')
DELETE TMemberCardAcctHist WHERE FCardId IN(SELECT FCardId FROM TImpMemberCourse WHERE <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE '%<EFBFBD><EFBFBD>%')
DELETE TMemberCard WHERE FCardId IN(SELECT FCardId FROM TImpMemberCourse WHERE <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE '%<EFBFBD><EFBFBD>%')
UPDATE TConsumeBill SET FCardId = 0 ,FCardNO = ''
WHERE FCardId IN(SELECT FCardId FROM TImpMemberCourse WHERE <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE '%<EFBFBD><EFBFBD>%')
SELECT * FROM TConsumeBill WHERE FCardId IN(SELECT FCardId FROM TImpMemberCourse WHERE <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE '%<EFBFBD><EFBFBD>%')
UPDATE TImpMemberCourse SET FExpiredDate = nULL WHERE FExpiredDate = '1900-01-01 00:00:00.000' AND FIsCourse = 1
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FPurAmount,FFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice,FState)
SELECT FCardId,FMemId,FCardTypeId,0,FItemId,FCompId,FRemainTimes,FBalance,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'<EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>',FCalcMode,0,FState
FROM TImpMemberCourse AS A
WHERE A.FIsCourse = 1
-- AND <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE '%<EFBFBD><EFBFBD>%'
INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FCourseId,FItemId,FPackId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,FRemainPurTimes,FRemainFreeTimes,FCompId,FBillType,FBizType,FBillId,FBillNo,FBillDetailId,FRecordTime,FMemo)
SELECT Id = FCardId,MemId = FMemId,CardId = 0,CourseId = FCardTypeId,ItemId = FItemId,PackId = 0,Time = getdate(),InPurTimes = FRemainTimes,InFreeTimes =0,
OutPurTimes = 0,OutFreeTimes = 0,RemainPurTimes = FRemainTimes,RemainFreeTimes = 0,CompId = FCompId ,BillType = 'DR',BizType = 'Import',BillId = 0,BillNo = '',BillDetailId = 0,RecordTime = getdate(),Memo = '<EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
FROM TImpMemberCourse AS A
WHERE A.FIsCourse = 1
-- AND <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE '%<EFBFBD><EFBFBD>%'
SELECT * FROM TMember WHERE FMemId = 1139835837647134132
SELECT * FROM TImpMemberCourse WHERE FMemId = 1139835837647134132
SELECT * FROM TImpMember WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD> = 'L0532100302'
UPDATE A
SET A.FExpiredDate = B.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
FROM TMemberCard AS A,TImpMemberCourse AS B
WHERE A.FCardId = B.FCardId
AND A.FExpiredDate != B.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
--
<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>
UPDATE TImpMemberCourse SET FCardState = 1
UPDATE TImpMemberCourse SET FIsCourse = 0 WHERE FIsCourse IS NULL
SELECT * FROM TImpMemberCourse WHERE ISNULL(FIsCourse,0) = 0
UPDATE A
SET A.FCardTypeId = B.FId
FROM TImpMemberCourse AS A,TMemberCardType AS B
WHERE A.<EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>= B.FName
AND FIsCourse = 0
SELECT * FROM TImpMemberCourse WHERE FIsCourse = 0 AND FCardTypeId IS NULL
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId,
FMemo)
SELECT
FCardId AS FId,
FCardNo AS FNo,
FCardTypeId AS FTypeId,
(SELECT FValueType FROM TMemberCardType WHERE FId = FCardTypeId) AS FValueType,
FCompId AS FCompId,
FMemId AS FMemId,
FState AS FState,
FCreateDate AS FCreateDate,
FExpiredDate AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FCompId AS FSaleCompId,
0 AS FSaleBillId,
'' AS FMemo
FROM TImpMemberCourse
WHERE FCardTypeId IS NOT NULL
AND FIsCourse = 0
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 TImpMemberCourse
WHERE FCardTypeId IS NOT NULL
AND FIsCourse = 0
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(),'<EFBFBD><EFBFBD>Excel<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>'
FROM TImpMemberCourse AS A
WHERE FCardTypeId IS NOT NULL
AND FIsCourse = 0
SELECT * FROM TImpMemberCourse WHERE ״̬ = '<EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD>' AND FExpir
SELECT * FROM TMemberCard
SELECT FCardNO,sum(1)
FROM TImpMemberCourse
where FIsCourse = 0
GROUP BY FCardNO ORDER BY sum(1) DESC
SELECT * from TImpMemberCourse where FCardNO LIKE '532101370%'
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FCardNo = B.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
FROM TImpMemberCourse AS A,TImpMember AS B
WHERE A.CardId = B.CardId
ALTER TABLE TImpMemberCourse ADD FIndex INT
ALTER TABLE TImpMemberCourse ADD FSeq INT IDENTITY(1,1) NOT NULL
UPDATE A
SET A.FIndex = (SELECT COUNT(1) FROM TImpMemberCourse AS B WHERE B.FCardNo = A.FCardNo AND A.FIsCourse = B.FIsCourse AND B.FSeq > A.FSeq ) + 1
FROM TImpMemberCourse AS A
WHERE A.FIsCourse = 0
SELECT * FROM TImpMemberCourse
UPDATE TMemberCard SET FExpiredDate = '9000-01-01' WHERE FExpiredDate = '1900-01-01'
UPDATE TImpMemberCourse SET FCardno = REPLACE(FCardno,'.1','')
UPDATE TImpMemberCourse SET FCardno = REPLACE(FCardno,'.2','')
UPDATE TImpMemberCourse SET FCardno = REPLACE(FCardno,'.3','')
UPDATE TImpMemberCourse SET FCardno = REPLACE(FCardno,'.4','')
UPDATE TImpMemberCourse SET FCardno = REPLACE(FCardno,'.5','')
UPDATE TImpMemberCourse SET FCardno = REPLACE(FCardno,'.9','')
UPDATE TImpMemberCourse SET FCardno = REPLACE(FCardno,'.8','')
UPDATE TImpMemberCourse SET FCardno = FCardno + '.' + CAST(Findex AS VARCHAR)
WHERE FIndex >1
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,
FCreateDate AS FCreateDate,
FGender AS FGender,
FBirthdayType 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,
0 AS FPoint,
1 AS FRecvConsSMS,
1 AS FRecvBulkSMS,
'' AS FMemo,
'' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
from TImpMemberInfo
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƴ̴<EFBFBD>ֵ<EFBFBD><EFBFBD>
ALTER TABLE TImpMember ADD FExpiredDate DATETIME
ALTER TABLE TImpMember ADD FCreateDate DATETIME
SELECT * FROM TImpMember
SELECT ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> + <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FROM TImpMember
WHERE CAST(ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT) + CAST(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT) > 0
SELECT * FROM TImpMember
UPDATE TMemberCardType SET FName ='<EFBFBD><EFBFBD><EFBFBD>ֵ' WHERE FNo = 'Course'
UPDATE TImpMember SET FExpiredDate = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
UPDATE TImpMember SET FCreateDate = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
UPDATE TImpMember SET FCardNo = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FCompId = 1
--
UPDATE A
SET A.FMemId = B.FMemId
FROM TImpMember AS A,TImpMemberInfo AS B
WHERE A.<EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = B.<EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FCardTypeId = 6
UPDATE TImpMember SET FBalance = CAST(ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT) + CAST(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT)
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId,
FMemo)
SELECT
FCardId AS FId,
FCardNo AS FNo,
FCardTypeId AS FTypeId,
(SELECT FValueType FROM TMemberCardType WHERE FId = FCardTypeId) AS FValueType,
FCompId AS FCompId,
FMemId AS FMemId,
1 AS FState,
FCreateDate AS FCreateDate,
FExpiredDate AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FCompId AS FSaleCompId,
0 AS FSaleBillId,
'' AS FMemo
FROM TImpMember
SELECT * FROM TMemberCardType
UPDATE TMemberCardType SET FNo = '' WHERE FId = 6
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
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(),'<EFBFBD><EFBFBD>Excel<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>'
FROM TImpMember AS A
WHERE FCardTypeId IS NOT NULL
AND FIsCourse = 0
UPDATE TMemberCard SET FCardNO = FCardNo + '.8' WHERE FCardNo NOT LIKE '%.%'
AND FCardNo + '.8' NOT IN(SELECT FCardNO FROM TMemberCard)
AND FCardId != 0
SELECT * FROM TMemberCard WHERE FCardNo NOT LIKE '%.%'
use qingdao_vstar
SELECT * FROM TMember WHERE FMobilePhone = '15269218016'
UPDATE TMemberCardType SET FMATERIAL = 2
SELECT * FROM TMemberCardType
SELECT * FROM TImpMemberCourseHist
SELECT * FROM TImpMemberCourse
UPDATE A
SET A.FCardNO = B.FCardnO
from TCOnsumeBill AS A,TMemberCard AS B
WHERE A.FCardId = B.FCardId
SELECT * FROM TImpMemberCourse
SELECT * FROM TImpMember WHERE FCardNO = ''
SELECT * FROM TImpMember WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE '<EFBFBD><EFBFBD>%'
UPDATE TMemberCard SET FExpiredDate = '9000-01-01' WHERE
UPDATE A
SET A.FExpiredDate = B.FExpiredDate
FROM TImpMemberCourse AS B,TMemberCard AS A
WHERE A.FCardID = b.FCardId
SELECT * FROM TMemberCard
SELECT * FROM TImpMemberCourseHist
select left('m7PhMEYqsWVxMkFlidZ1XKus8ngdp85S3KfaJqU9HGT',32)
ALTER TABLE TImpMemberCourseHist ADD FEmployees VARCHAR(1000)
ALTER TABLE TImpMemberCourseHist ADD FRemainTimes DECIMAL(18,6)
ALTER TABLE TImpMemberCourseHist ADD FBillType VARCHAR(1000)
ALTER TABLE TImpMemberCourseHist ADD FBizType VARCHAR(1000)
ALTER TABLE TImpMemberCourseHist ADD FId BIGINT
ALTER TABLE TImpMemberCourseHist ADD FInPurAmount DECIMAL(18,6)
ALTER TABLE TImpMemberCourseHist ADD FOutPurAmount DECIMAL(18,6)
ALTER TABLE TImpMemberCourseHist ADD FInPurTimes DECIMAL(18,6)
ALTER TABLE TImpMemberCourseHist ADD FOutPurTimes DECIMAL(18,6)
UPDATE TImpMemberCourseHist SET FEmployees = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD>
UPDATE TImpMemberCourseHist SET FId = dbo.FNNewId()
UPDATE TImpMemberCourseHist SET FBillType = 'DR'
UPDATE TImpMemberCourseHist SET FBizType =<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMemberCourseHist SET FRemainTimes = CAST(<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT)
UPDATE TImpMemberCourseHist SET FBillType ='DR_XF' WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE TImpMemberCourseHist SET FBizType ='DR_Item' WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE TImpMemberCourseHist SET FBillType ='DR_KK' WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE TImpMemberCourseHist SET FBizType ='DR_CourseSale' WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
DELETE TMemberCourseLog WHERE FBilltYPE LIKE 'DR%'
SELECT * FROM TImpMemberCourseHist WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD> = '2016-10-08 10:14:28'
SELECT * FROM TMember WHERE FMemNO = '532106105'
SELECT * FROM TImpMemberCourseHist WHERE FMemId = 1630559165388138822
UPDATE TImpMemberCourseHist SET FInPurTimes = cast(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT) WHERE cast(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT) >= 0
UPDATE TImpMemberCourseHist SET FOutPurTimes = cast(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT)WHERE cast(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT) < 0
UPDATE TImpMemberCourseHist SET FInPurAmount = cast(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT) WHERE cast(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT) >= 0
UPDATE TImpMemberCourseHist SET FOutPurAmount = cast(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT)WHERE cast(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AS FLOAT) < 0
INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FCourseId,FItemId,FPackId,FTime,FInPurTimes,FOutPurTimes,FInPurAmount,FOutPurAmount,FInFreeTimes,FOutPurTimes,FOutFreeTimes,FRemainPurTimes,FRemainFreeTimes,FCompId,FBillType,FBizType,FBillId,FBillNo,FBillDetailId,FRecordTime,FMemo,FEmployees)
SELECT Id = dbo.FNNewId(),MemId = FMemId,CardId = FCardId,CourseId = FCardTypeId,ItemId = FItemId,PackId = 0,Time = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>,FInPurTimes,FOutPurTimes,FInPurAmount,FOutPurAmount,InFreeTimes =0,
OutPurTimes = 0,OutFreeTimes = 0,RemainPurTimes = FRemainTimes,RemainFreeTimes = 0,CompId = FCompId ,BillType = FBillType,BizType = FBizType,BillId = 0,BillNo = '',BillDetailId = 0,RecordTime = getdate(),Memo = '<EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>',FEmployees
FROM TImpMemberCourseHist AS A
WHERE FCardId IN(SELECT FId FROM TMemberCourse)
UPDATE A
SET A.FItemId = B.FId
FROM TImpMemberCourseHist AS A,TItem AS B
WHERE A.<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>= b.fname
UPDATE A
SET A.FItemId = B.FItemid
FROM TImpMemberCourseHist AS A,TCourse AS B
WHERE A.FCardTypeId= b.FId
-- AND <EFBFBD>ײ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LIKE '%<EFBFBD><EFBFBD>%'