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

565 lines
19 KiB

1 year ago
SELECT CardTypeName FROM TImpMember
WHERE CardTypeName NOT IN(SELECT FCardTypeName FROM TImpCardType)
GROUP BY CardTypeName
SELECT * FROM TCompany
SELECT count(*) FROM TImpMember WHERE ID NOT IN(SELECT FCardId FROM TImpMemberAcct)
SELECT * FROM TImpMemberAcct
WHERE 1=1
AND intAccountCate != 1
AND FCardId = 3257267
SELECT * FROM TImpMemberPack
WHERE FCardId = 3257267
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD>
ALTER TABLE TImpMemberPack ADD FMemId BIGINT
ALTER TABLE TImpMemberPack ADD FCreateDate DATETIME
ALTER TABLE TImpMemberPack ADD FExpiredDate DATETIME
ALTER TABLE TImpMemberPack ADD FItemId BIGINT
ALTER TABLE TImpMemberPack ADD FCourseId BIGINT
ALTER TABLE TImpMemberPack ADD FMemCourseId BIGINT
UPDATE A
SET A.FCreateDate = dtmCreateTime,
A.FExpiredDate = dtmLimitDate
FROM TImpMemberPack AS A
UPDATE A
SET A.FMemCourseId = dbo.FNnewId()
FROM TImpMemberPack AS A
WHERE A.FMemCourseId IS NULL
UPDATE A
SET A.FMemId = B.FMemId
FROM TImpMemberPack AS A ,TImpMember AS B
WHERE A.FCardId = B.Id
UPDATE A
SET A.FItemId = B.FItemId,
A.FCourseId = B.FId
FROM TCourse AS B,TImpMemberPack AS A
WHERE B.FNo = '1001L1'
SELECT * FROM TImpMember WHERE Id = 2934498
SELECT * FROM TImpError
delete TImpError
SELECT * FROM TMemberCourse
SELECT *INTO TMember_Exist FROM TMember WHERE FMemNo IN(SELECT CardNo FROM TImpMember)
SELECT * FROM TImpMember WHERE Credit != 0
SELECT * FROM TUser
SELECT * FROM TImpMember WHERE CardNo = '800128'
CREATE TABLE TImpError
(
CardId BIGINT,
Error VARCHAR(7000)
)
ALTER TABLE TImpMember ADD FIsLoad BIT NOT NULL DEFAULT 0
ALTER TABLE TImpMember ADD FCardTypeName VARCHAR(100)
ALTER TABLE TImpMember ADD FMemId BIGINT
ALTER TABLE TImpMember ADD FMemNo VARCHAR(50)
ALTER TABLE TImpMember ADD FCardNo VARCHAR(50)
ALTER TABLE TImpMember ADD FName VARCHAR(50)
ALTER TABLE TImpMember ADD FGender INT
ALTER TABLE TImpMember ADD FCardState INT
ALTER TABLE TImpMember ADD FMobile VARCHAR(50)
ALTER TABLE TImpMember ADD FCardTypeId BIGINT
ALTER TABLE TImpMember ADD FCourseId BIGINT
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 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
UPDATE TImpMember SET FMemId = MemberId
UPDATE TImpMember SET FCardId = ID
UPDATE TImpMember SET FMemNo = Cardno
UPDATE TImpMember SET FCardno = Cardno
UPDATE TImpMember SET FName = MemberName
UPDATE TImpMember SET FMobile = MobilePhone
UPDATE TImpMember SET FGender = CASE WHEN Sex = '<EFBFBD><EFBFBD>' THEN 1 ELSE '0' END
UPDATE TImpMember SET FBalance = CAST(Balance AS FLOAT)
UPDATE TImpMember SET FRemainTimes = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FPurTimes = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FPurAmount = <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FCreateDate = CreateTime
UPDATE TImpMember SET FCompId = (SELECT FId FROM TCompany WHERE FNo = '003')
UPDATE TImpMember SET FArrear = Ƿ<EFBFBD><EFBFBD>
UPDATE TImpMember SET FMemo = remark
UPDATE TImpMember SET FPoint = cast(JF as float)
UPDATE TImpMember SET FPoint = 0
UPDATE TImpMember SET FCardState = 0
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FBirthday = NULL
UPDATE TImpMember SET FBirthdayType = 'G'
UPDATE TImpMember SET FBirthdayType = 'L' WHERE IsCNBirth = 1
ALTER TABLE TImpMember ADD FBirthdayStr VARCHAR(10)
UPDATE TImpMember SET FBirthdayStr = REPLACE(Birth,' ','')
UPDATE TImpMember SET FBirthdayStr = REPLACE(REPLACE(FBirthdayStr,'0000','9999'),'1111','9999')
UPDATE TImpMember SET FBirthdayStr = '9999-11-11' WHERE FBirthdayStr = '1-11-11'
UPDATE TImpMember SET FBirthdayStr = '' WHERE FBirthdayStr = '9999-11-11'
UPDATE TImpMember SET FBirthdayStr = '9999-11-11' WHERE FBirthdayStr = '11-11-11'
UPDATE TImpMember SET FBirthdayStr = '9999-11-11' WHERE FBirthdayStr = '111-11-11'
UPDATE TImpMember SET FBirthdayStr =REPLACE(FBirthdayStr,'006','996')
UPDATE TImpMember SET FBirthdayStr =REPLACE(FBirthdayStr,'007','997')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'008','998')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'097','999')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'098','999')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'099','999')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'095','999')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'1000','9999')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'0-','9999-') WHERE FBirthdayStr = '0-12-04'
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-1-','-01-')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-2-','-02-')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-3-','-03-')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-4-','-04-')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-5-','-05-')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-6-','-06-')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-7-','-07-')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-8-','-08-')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-9-','-09-')
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-9','-09') WHERE FBirthdayStr LIKE '%-9' AND Len(FBirthdayStr) < 10
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-1','-01') WHERE FBirthdayStr LIKE '%-1' AND Len(FBirthdayStr) < 10
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-2','-02') WHERE FBirthdayStr LIKE '%-2' AND Len(FBirthdayStr) < 10
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-3','-03') WHERE FBirthdayStr LIKE '%-3' AND Len(FBirthdayStr) < 10
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-4','-04') WHERE FBirthdayStr LIKE '%-4' AND Len(FBirthdayStr) < 10
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-5','-05') WHERE FBirthdayStr LIKE '%-5' AND Len(FBirthdayStr) < 10
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-6','-06') WHERE FBirthdayStr LIKE '%-6' AND Len(FBirthdayStr) < 10
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-7','-07') WHERE FBirthdayStr LIKE '%-7' AND Len(FBirthdayStr) < 10
UPDATE TImpMember SET FBirthdayStr = REPLACE(FBirthdayStr,'-8','-08') WHERE FBirthdayStr LIKE '%-8' AND Len(FBirthdayStr) < 10
UPDATE TImpMember SET FBirthdayStr = '' where FBirthdayStr ='--'
UPDATE TImpMember SET FBirthdayStr =REPLACE(FBirthdayStr,'000','9999')where len(FBirthdayStr) = len('000-02-17')
UPDATE TImpMember SET FBirthdayStr =REPLACE(FBirthdayStr,'001','9999')where len(FBirthdayStr) = len('000-02-17')
UPDATE TImpMember SET FBirthdayStr =REPLACE(FBirthdayStr,'001','9999')where len(FBirthdayStr) = len('000-02-17')
UPDATE TImpMember SET FBirthdayStr ='19' + FBirthdayStr where len(FBirthdayStr) = len('87-09-29')
UPDATE TImpMember SET FBirthdayStr ='9999' + FBirthdayStr where FBirthdayStr like '-%'
UPDATE TImpMember SET FBirthdayStr ='19' + FBirthdayStr where len(FBirthdayStr) = len('84-5-25') AND FBirthdayStr > '5'
UPDATE TImpMember SET FBirthdayStr ='999' + FBirthdayStr where len(FBirthdayStr) = len('0-01-04')
UPDATE TImpMember SET FBirthdayStr = '' WHERE FBirthdayStr = '9999-02-30'AND FBirthdayType = 'G'
UPDATE TImpMember SET FBirthdayStr = '9996-02-29'
WHERE 1=1
AND FBirthdayStr LIKE '%02-29' OR FBirthdayStr LIKE
AND FBirthdayType = 'L'
SELECT FBirthdayStr FROM TImpMember WHERE FBirthdayStr LIKE '___-__-__'
UPDATE TImpMember SET FBirthdayStr = '9999' + SUBSTRING(FBirthdayStr,4,6) WHERE FBirthdayStr LIKE '___-__-__'
SELECT FBirthdayStr ,FBirthdayType
,CAST(FBirthdayStr AS DATETIME)
FROM TImpMember
WHERE 1=1
AND LEN(FBirthdayStr) = 10
AND FBirthdayStr > '9999-02-28'
AND FBirthdayStr != ''
ORDER BY FBirthdayStr ASC
SELECT FBirthdayStr FROM TImpMember
UPDATE TImpMember SET FBirthday = FBirthdayStr
WHERE LEN(FBirthdayStr) = 10
SELECT Birth FROM TImpMember
WHERE LEN(Birth) = 10
AND Birth NOT LIKE '00%'
SELECT Birth FROM TImpMember
--״̬
UPDATE TMemberCardAccount SET FExpiredDate = null
SELECT * FROM TImpMember WHERE StatusReason NOT IN('<EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<EFBFBD><EFBFBD>ʧ','<EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
UPDATE TImpMember SET FCardState = 1 WHERE StatusReason = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE TImpMember SET FCardState = 1 WHERE StatusReason = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE TImpMember SET FCardState = 16 WHERE StatusReason = '<EFBFBD><EFBFBD>ʧ'
UPDATE TImpMember SET FCardState = 1 WHERE StatusReason = '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
SELECT FCardnO,fnAME, FMobile,FBalance,StatusReason FROM TImpMember WHERE FCardNo = '6011238'
UPDATE TImpMember SET F
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FCardTypeName = CardTypeName + '[' +CAST(Discount * CAST(10.0 AS FLOAT) AS VARCHAR) + '<EFBFBD><EFBFBD>]'
FROM TImpMember AS A
UPDATE A SET A.FCardTypeId = B.FCardTypeId
FROM TImpMember AS A,TImpCardType AS B
WHERE A.FCardTypeName = B.FCardTypeName
SELECT FCardTypeName FROM TImpMember
WHERE FCardTypeId IS NULL
GROUP BY FCardTypeName
--<EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SELECT FMemNo,SUM(1) FROM TIMpMEMBER
GROUP BY FMemNo
ORDER BY SUM(1) DESC
SELECT FCardnO,SUM(1) FROM TIMpMEMBER
GROUP BY FCardnO
ORDER BY SUM(1) DESC
SELECT FMemId,SUM(1) FROM TIMpMEMBER
GROUP BY FMemId
ORDER BY SUM(1) DESC
SELECT * FROM TIMpMEMBER WHERE FMemID = 189072
SELECT CardnO,MemberCode FROM TImpMember WHERE FCardNo != FMemNo
AND FCompId = dbo.FNCompId('001')
DELETE TImpCardType
SELECT * FROM TImpMember WHERE MemberID = 189072
SELECT * FROM TImpMember WHERE MemberCode = '00004'
SELECT * FROM TImpMember WHERE Balance > '9'
SELECT * FROM TImpMember
SELECT * FROM TCompany
SELECT ShopName,ShopId,FCompId FROM TImpMember
GROUP BY ShopName,FCompId,ShopId
UPDATE TImpMember SET FCompId = dbo.FNCompId('001') WHERE ShopId = 697
UPDATE TImpMember SET FCompId = dbo.FNCompId('002') WHERE ShopId = 784
UPDATE TImpMember SET FCompId = dbo.FNCompId('003') WHERE ShopId = 805
UPDATE TImpMember SET FCompId = dbo.FNCompId('004') WHERE ShopId = 3330
UPDATE TImpMember SET FCompId = dbo.FNCompId('004') WHERE ShopId = 18855
UPDATE TImpMember SET FCompId = dbo.FNCompId('002') WHERE ShopId = 17239
SELECT * FROM TImpShopInfo
INSERT TImpCardType(FCardTypeId,FCardTypeNo,FCardTypeName)
SELECT dbo.FNNewId(),
CardTypeName + '[' +CAST(Discount * CAST(10.0 AS FLOAT) AS VARCHAR) + '<EFBFBD><EFBFBD>]' ,
CardTypeName + '[' +CAST(Discount * CAST(10.0 AS FLOAT) AS VARCHAR) + '<EFBFBD><EFBFBD>]'
FROM TImpMember
GROUP BY Discount ,CardTypeName
ORDER BY CardTypeName
delete TMemberCardType WHERE FId > 111
WHERE FId NOT IN(SELECT FCardTypeiD FROM TMemberCardTypeSub)
AND FId > 11
SELECT * FROM TMemberCardType
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
WHERE FCardTypeNo NOT IN(SELECT FNO FROM TMemberCardType)
ORDER BY FCardTypeName
GROUP BY CardTypeId,CardTypeName
UPDATE
DROP TABLE TImpCardType
CREATE TABLE TImpCardType
(
FShopId INT ,
FCardTypeName VARCHAR(500),
FCardTypeNo VARCHAR(50),
FCardTypeId BIGINT
)
SELECT A.CardTypeName,B.FNo,B.FId FROM TImpMember AS A,TMemberCardType AS B
WHERE A.CardTypeName NOT IN(SELECT FCardTypeName FROM TImpCardType)
AND A.CardTypeName = B.FName
GROUP BY A.CardTypeName,B.FNo,B.FId
UPDATE TMemberCard SET FExpiredDate = '9000-01-01'
SELECT * FROM TMemberCardType WHERE FName LIKE '%<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%'
SELECT * FROM TUser
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʷ
SELECT * FROM TImpMemberLog
ALTER TABLE TImpMemberLog ADD FMemId BIGINT
ALTER TABLE TImpMemberLog ADD FBillNo VARCHAR(50)
ALTER TABLE TImpMemberLog ADD FBizType VARCHAR(50)
ALTER TABLE TImpMemberLog ADD FContent VARCHAR(1000)
ALTER TABLE TImpMemberLog ADD FAmount DECIMAL(18,6)
ALTER TABLE TImpMemberLog ADD FTime DATETIME
ALTER TABLE TImpMemberLog ADD FId VARCHAR(50)
ALTER TABLE TImpMemberLog ADD FEmployee VARCHAR(1000)
ALTER TABLE TImpMemberLog ADD FQuantity DECIMAL(18,6)
ALTER TABLE TImpMemberLog ADD FCompId BIGINT
UPDATE A
SET A.FMemId = M.FMemId
FROM TImpMemberLog AS A,TMember AS M
WHERE A.<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD> = M.FMemNo
SELECT * FROM TImpMemberAcctHist
UPDATE TImpMemberLog SET FBillNo = <EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD>
UPDATE TImpMemberLog SET FContent = <EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMemberLog SET FQuantity = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMemberLog SET FAmount = <EFBFBD>ۿ۽<EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMemberLog SET FEmployee = ISNULL(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD>,'')
UPDATE TImpMemberLog SET FTime = <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMemberLog SET FQuantity = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMemberLog SET FId = dbo.FNNewId()
UPDATE TImpMemberLog SET FCompId = (SELECT FId FROM TCompany WHERE FNo = '003')
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,
MIN(FMemNo) AS FMemNo,
FName AS FName,
dbo.FNGetFirstPinYin(FName),
0 AS FTypeId,
FCompId AS FCompId,
MIN(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,
'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5
from TImpMember
WHERE FMemNo NOT IN(SELECT FMemNo FROM TMember)
group by FMemId,FName,FCompId,FGender,FBirthdayType,FBirthday,FMobile
SELECT FMemId,sum(1)
FROM TImpMember
GRoup by FMemId
order by sum(1) desc
AND FMemId IN(SELECT FMemId FROM TMember)
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,
FCardState AS FState,
FCreateDate AS FCreateDate,
DATEADD(year,1, FCreateDate) AS FExpiredDate,
0 AS FTotalTimes,
0 AS FUsedTimes,
FCompId AS FSaleCompId,
0 AS FSaleBillId,
FMemo AS FMemo
FROM TImpMember
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 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,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
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FPurAmount,FFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
SELECT FMemCourseId,FMemId,FCourseId,0,FItemId,1,0,0,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',2,0
FROM TImpMemberPack AS A
UPDATE TMemberCourseImportEx SET FId = dbo.FNNewId()
INSERT INTO TMemberCourseHist(FId,FMemId,FMemCourseId,FPackId,FCourseId,FTime,FPurTimes,FFreeTimes,FUsePurTimes,FUseFreeTimes,
FPurAmount,FFreeAmount,FUsePurAmount,FUseFreeAmount,FCompId,
FBillType,FBizType,FTransId,FTransNo,FTransDetailId)
SELECT dbo.FNNewId(),FMemId,FMemCourseId,0,FCourseId,FTime = getdate(),0,0,0,0,
0,0,0,0,1,
'DR','Import',0,'',0
FROM TImpMemberPack AS A
SELECT * FROM TMember WHERE FMemId IN(SELECT FMemId FROM TMemberCOurse)
SELECT FMemId,MIN(FId) FROM TMemberCourse
GROUP BY FMemId
DELETE TMemberCOurse WHERE FId NOT IN( SELECT MIN(FId) FROM TMemberCourse
GROUP BY FMemId)
UPDATE TImpMember SET FIsLOAD = 0
SELECT * FROM TImpMemberLog
SELECT * FROM TImpMember WHERE FCardNO = '6011238'
SELECT
INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo)
SELECT A.FId,A.FMemId,A.FTime,0,A.FCompId,'DR','Import',FBillNo,FContent,FAmount,FQuantity,FAmount,'',FEmployee,''
FROM TImpMemberAcctHist AS A
WHERE ISNULL(FMemId,0) != 0
AND <EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD><EFBFBD><EFBFBD> != ''
WHERE A.FNo = hykh
delete TImpError
ALTER TABLE TImpMemberAcctHist ADD FCompId BIGINT
ALTER TABLE TImpMemberAcctHist ADD FShopId BIGINT
ALTER TABLE TImpMemberAcctHist ADD FMemId BIGINT
UPDATE A
SET A.FMemId = B.FMemId
FROM TImpMemberAcctHist AS A,TImpMEMBER AS B
WHERE A.FCardId = B.FCardId
UPDATE A
SET A.FShopId = B.ShopId
FROM TImpMember AS B,TImpMemberAcctHist AS A
WHERE A.vhrShopName = B.ShopName
UPDATE TImpMemberAcctHist SET FCompId = dbo.FNCompId('001') WHERE fShopId = 697
UPDATE TImpMemberAcctHist SET FCompId = dbo.FNCompId('002') WHERE fShopId = 784
UPDATE TImpMemberAcctHist SET FCompId = dbo.FNCompId('003') WHERE fShopId = 805
UPDATE TImpMemberAcctHist SET FCompId = dbo.FNCompId('004') WHERE fShopId = 3330
INSERT INTO TMemberCardOldAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBizType,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo)
SELECT intId,FMemId,FCardId,3,ISNULL(dtmOPDateTime,'1753-01-01'),0,ISNULL(FCompId,0),vhrdatatype,vhrBillCode,cast(decinmoney as float),cast(decoutmoney as float),0,0,dtmOPDateTime,vhrdatatype
FROM TImpMemberAcctHist
SELECT * FROM TImpMemberAcctHist WHERE FCompiD IS NULL
SELECT * FROM TMemberCard WHERE FCardId = 38677
SELECT * FROM TImpMember WHERE CardNo = '8010735'
SELECT * FROM TImpError WHERE CardId = 38677
SELECT