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/艺尚/SQLQuery12.sql

543 lines
18 KiB

1 year ago
SELECT * FROM TImpMember
DROP TABLE TImpCardType
CREATE TABLE TImpCardType
(
FId BIGINT,
FNo VARCHAR(20),
FName VARCHAR(30),
FType VARCHAR(30),
FValueType INT
)
INSERT TImpCardType
SELECT dbo.FNNewId(),<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> + '[' + <EFBFBD>ۿ<EFBFBD> + '<EFBFBD><EFBFBD>]',<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ,CASE WHEN <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = '<EFBFBD>ƴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' THEN 3 ELSE 1 END FROM TImpMember
GROUP BY <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD>ۿ<EFBFBD>
DELETE TImpTransLog
SELECT * FROM TImpTransLog
SELECT ' ALTER TABLE TImpTransLog ALTER COLUMN ' + name + ' VARCHAR(500)'
FROM syscolumns WHERE id = object_id('TImpTransLog')
AND name != 'FMemId'
ALTER TABLE TImpTransLog ALTER COLUMN
alter TABLE TImpTransLog DROP COLUMN FRowVersion
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 FBalance DECIMAL(18,6)
ALTER TABLE TImpMember ADD FBalance2 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 FCustom1 VARCHAR(100)
UPDATE TImpMember SET FMemId = <EFBFBD><EFBFBD>ԱID
UPDATE TImpMember SET FCardId = <EFBFBD><EFBFBD>ID
UPDATE TImpMember SET FCardNo = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FMemNo = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FName = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FMobile = <EFBFBD>ֻ<EFBFBD>
UPDATE TImpMember SET FGender = CASE WHEN <EFBFBD>Ա<EFBFBD> = '<EFBFBD><EFBFBD>' THEN 1 ELSE '0' END
UPDATE TImpMember SET FCreateDate = ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpMember SET FExpiredDate = REPLACE(ʧЧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,' ','') WHERE ʧЧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> != '' AND ʧЧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> != '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ'
UPDATE TImpMember SET FExpiredDate = DATEADD(YEAR,100,ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) WHERE FExpiredDate IS NULL
UPDATE TImpMember SET FArrear = Ƿ<EFBFBD><EFBFBD>
UPDATE TImpMember SET FMemo = <EFBFBD><EFBFBD>ע
DECLARE
ALTER TABLE TImpMember ADD FPointText VARCHAR(100)
UPDATE TImpMember SET FPointText = replace(replace(replace(replace(<EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,'<EFBFBD><EFBFBD>',''),char(10),''),char(13),''),' ','')
UPDATE TImpMember SET FPoint = CAST(FPointText AS FLOAT)
SELECT <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> FROM TImpMember WHERE <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> NOT LIKE '%<EFBFBD><EFBFBD>%'
UPDATE TImpMember SET FCompId = 1
SELECT <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> FROM TImpMember
UPDATE TImpMember SET FMemo = FMemo + '<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɽ·<EFBFBD>' WHERE <EFBFBD><EFBFBD>˾ID = 130011
UPDATE TImpMember SET FMemo = FMemo + '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>' WHERE <EFBFBD><EFBFBD>˾ID = 130012
UPDATE TImpMember SET FMemo = FMemo + '<EFBFBD><EFBFBD>԰<EFBFBD><EFBFBD>·<EFBFBD>' WHERE <EFBFBD><EFBFBD>˾ID = 130013
UPDATE TImpMember SET FMemo = FMemo + '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>' WHERE <EFBFBD><EFBFBD>˾ID = 130016
UPDATE A
SET A.FCardTypeId = B.FId
FROM TImpMember AS A,TImpCardType AS B
WHERE A.<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> + '[' + A.<EFBFBD>ۿ<EFBFBD> + '<EFBFBD><EFBFBD>]' = B.FName
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-')
UPDATE TImpMember SET FCardNo = <EFBFBD><EFBFBD><EFBFBD><EFBFBD> + '.2' ,FMemNo = <EFBFBD><EFBFBD><EFBFBD><EFBFBD> + '.2'
WHERE FMemId = 8349508648302214543
UPDATE TImpMember SET FMemId = 6273693882209312287 WHERE FMemId = 8349508648302214543
SELECT * FROM TImpMember WHERE FMobile = '15039585857'
--
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SELECT * FROM TImpMember WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = '<EFBFBD>ƴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE TImpMember SET <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = REPLACE(REPLACE( REPLACE(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,char(10),''),char(13),''),' ','')
UPDATE TImpMember SET FRemainTimes = REPLACE(SUBSTRING(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,CHARINDEX('<EFBFBD><EFBFBD>:',<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) + 2,LEN(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)),'<EFBFBD><EFBFBD>','')
FROM TImpMember WHERE <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = '<EFBFBD>ƴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
UPDATE TImpMember SET FBalance = CAST(REPLACE( REPLACE(REPLACE(REPLACE(LEFT(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,CHARINDEX('Ԫ',<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) + 3),'Ԫ',''),' ','') ,char(10),''),' ','')
AS float)
UPDATE TImpMember SET FBalance2 = CAST(REPLACE( REPLACE(REPLACE(REPLACE(LEFT(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,CHARINDEX('Ԫ',<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) + 3),'Ԫ',''),' ','') ,char(10),''),' ','')
AS float)
----------
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ALTER TABLE TImpMember ADD FSeq INT IDENTITY
ALTER TABLE TImpMember ADD FIndex INT
UPDATE TImpMember SET FCardNo = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE A
SET A.FIndex = 1+(SELECT COUNT(1) FROM TImpMember AS B WHERE A.<EFBFBD><EFBFBD><EFBFBD><EFBFBD> = B.<EFBFBD><EFBFBD><EFBFBD><EFBFBD> AND (A.FCreateDate > B.FCreateDate OR (A.FCreateDate = B.FCreateDate AND (A.FSeq > B.FSeq) )))
FROM TImpMember AS A
UPDATE TImpMember SET FCardNo = <EFBFBD><EFBFBD><EFBFBD><EFBFBD> + '.' + CAST(FIndex AS VARCHAR) WHERE FIndex > 1
UPDATE TImpMember SET FMemNo = FCardNo
SELECT * FROM TImpMember
UPDATE A
SET A.FMemNo = B.FMemNo
FROM TImpMember AS A,TImpMember AS B
WHERE A.FMemId = B.FMemId
AND A.FIndex > 1
AND B.FIndex = 1
--<EFBFBD><EFBFBD>ԱIDû<EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD>
SELECT * FROM TImpMember AS A WHERE 1=1
AND A.FMemId IN(
select FMemId from TImpMember
GROUP BY FMemId
HAVING(SUM(1) > 1)
)
SELECT * FROM TImpMember WHERE FMobile = '13853278520'
SELECT * FROM TImpMember WHERE FCardNo = '00066.2'
SELECT FCardNo,SUM(1) AS Cnt FROM TImpMember
GROUP BY FCardNo
ORDER BY SUM(1) DESC
SELECT FMemNo,FMobile,SUM(1) AS Cnt FROM TImpMember
GROUP BY FMemNo ,FMobile
ORDER BY SUM(1) DESC
SELECT * FROM TImpMember WHERE FIndex = 0 ORDER BY FIndex DESC
SELECT FMemNo,SUM(1) AS Cnt FROM TImpMember
GROUP BY FMemNo
ORDER BY SUM(1) DESC
UPDATE A
SET A.FCardNo = A.FMobile,
A.FMemno = A.FMobile
from TImpMember AS A
WHERE FMemNo IN
(
SELECT FMemNo FROM (
SELECT FMemNo,SUM(1) AS Cnt FROM TImpMember
GROUP BY FMemNo
) AS T
WHERE T.Cnt > 1
)
DELETE TImpMember WHERE FSeq = 1454
SELECT * FROM TImpMember WHERE FCardId = 222519814
delete TMemberCardType WHERE FId > 100
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 ,FName,FName,FValueType,2,0,0,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
FROM TImpCardType
ORDER BY FNo
UPDATE TMemberCardType SET FAllowRchg = 1
UPDATE TMemberCardType SET FAllowSale = 1
UPDATE TMemberCardType SET FEnabled = 1
UPDATE TMemberCardType SET FNeedPush = 1
UPDATE TMemberCardType SET FMaterial = 2
SELECT * FROM TMemberCardType
UPDATE TMemberCardType SET FValueType = 1
UPDATE A
SET A.FValueType = 3
FROM TMemberCardType AS A,TImpCardType AS B
WHERE A.FId = B.FId
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,
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,
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
GROUP BY FMemId,FMemNo,FName,FMobile,FGender,FCompId,FBirthdayType,FBirthday,FCreateDate,FPoint
/*
SELECT * FROM TImpMember
WHERE FMemId IN(
SELECT FMemId,FMemNo,FName,FMobile,FGender,FCompId ,FBirthdayType ,FBirthday,FCreateDate,FPoint
INTO #Temp
FROM TImpMember
GROUP BY FMemId,FMemNo,FName,FMobile,FGender,FCompId ,FBirthdayType ,FBirthday,FCreateDate,FPoint
ORDER BY SUM(1) DESC
)
SELECT FMemId
FROM #Temp
GROUP BY FMemId
HAVING(SUM(1)) > 1
SELECT * FROM TImpmEMBER WHERE FMemId = 25006217
UPDATE TImpMember SET FMemNo = '0000330' WHERE FMemId = 25463627
UPDATE TImpMember SET FMemNo = '0000055' WHERE FMemId = 25006217
*/
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FCardFaceNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId,
FMemo)
SELECT
FCardId AS FId,
FCardNo AS FNo,
FCardNo AS FFaceNo,
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,
ISNULL(FRemainTimes,0) AS FTotalTimes,
0 AS FUsedTimes,
FCompId AS FSaleCompId,
0 AS FSaleBillId,
FMemo AS FMemo
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
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>ʢ<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>'
FROM TImpMember AS A
INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo)
SELECT FMemId,dbo.FNNewId(),FCardId AS FCardId,10,FBalance2,FBalance2,0,FCreateDate,NULL AS FExpiredDate,''
FROM TImpMember AS A
WHERE FBalance2 != 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,10,getdate(),A.FCardTypeId,A.FCompId,'DR','Import',0,'',A.FBalance2,0,A.FBalance2,0,getdate(),'<EFBFBD><EFBFBD>ʢ<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>'
FROM TImpMember AS A
WHERE FBalance2 != 0
SELECT * FROM TImpMember AS A
WHERE FBalance2 != 0
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 NOT EXISTS(SELECT TOP 1 1 FROM TMemberCardTypeSub AS B WHERE B.FCompId = C.FId AND B.FCardTypeId = I.FId)
SELECT * FROM TMemberCard WHERE FMemo != ''
SELECT * FROM TImpMember where <EFBFBD><EFBFBD>ע != ''
SELECT * FROM TImpMember WHERE FCardId = 210918739
SELECT * FROM TImpMEMBER WHERE FCardNO = '000088'
--<EFBFBD>Ƴ<EFBFBD>
DROP TABLE TImpCourse
SELECT * FROM TImpCourse
ALTER TABLE TImpCourse ADD FCardId BIGINT default dbo.FNNewId()
ALTER TABLE TImpCourse ADD FMemId BIGINT
ALTER TABLE TImpCourse ADD FCompId BIGINT
ALTER TABLE TImpCourse ADD FMobile VARCHAR(20)
ALTER TABLE TImpCourse ADD FCardNO VARCHAR(20)
ALTER TABLE TImpCourse ADD FMemNo VARCHAR(20)
ALTER TABLE TImpCourse ADD FName VARCHAR(20)
ALTER TABLE TImpCourse ADD FItemNo VARCHAR(20)
ALTER TABLE TImpCourse ADD FItemName VARCHAR(20)
ALTER TABLE TImpCourse ADD FTimes VARCHAR(20)
ALTER TABLE TImpCourse ADD FRemainTimes VARCHAR(20)
ALTER TABLE TImpCourse ADD FAdjustPrice VARCHAR(20)
ALTER TABLE TImpCourse ADD FRemainAmount VARCHAR(20)
ALTER TABLE TImpCourse ADD FAmount VARCHAR(20)
ALTER TABLE TImpCourse ADD FExpiredDate DATETIME
ALTER TABLE TImpCourse ADD FItemId BIGINT
ALTER TABLE TImpCourse ADD FCourseId BIGINT
ALTER TABLE TImpCourse ADD FUsedTimes DECIMAL(18,6)
ALTER TABLE TImpCourse ADD FCreateDate DATETIME
ALTER TABLE TImpCourse ALTER COLUMN <EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD> VARCHAR(30)
DROP FUNCTION FNGetValue
GO
CREATE FUNCTION FNGetValue
(
@Str VARCHAR(8000),
@Key VARCHAR(1000)
)
RETURNS VARCHAR(1000)
AS
BEGIN
SELECT @Key = @Key + ':'
SELECT @Str= SUBSTRING(@Str,CHARINDEX(@Key,@Str) + LEN(@Key),LEN(@Str) )
DECLARE @Index INT
SELECT @Index = CHARINDEX(',',@Str)-1
IF @Index > 0
BEGIN
SELECT @Str = LEFT(@Str,@Index)
END
RETURN @Str
END
GO
UPDATE TImpCourse SET FCardId = dbo.FNNewid()
UPDATE TImpCourse SET FCompId = 1
UPDATE TImpCourse SET FMemId = <EFBFBD><EFBFBD>ԱID
UPDATE TImpCourse SET FCardNo = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpCourse SET FMemNo = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpCourse SET FName = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
UPDATE TImpCourse SET FMobile = <EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD>
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>
UPDATE A
SET A.FMemId = B.FMemId,
A.FCreateDate = B.FCreateDate
FROM TImpMember AS B,TImpCourse AS A
WHERE A.FMemNo = B.FMemNo
SELECT * FROM TImpMember WHERE FMemNO = '13687617668'
SELECT * FROM TImpCourse WHERE FMobile = '13687617668'
UPDATE TImpCourse SET FItemNo =dbo.FNGetValue(<EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD>Ŀ, '<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
UPDATE TImpCourse SET FItemName = dbo.FNGetValue(<EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD>Ŀ, '<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
UPDATE TImpCourse SET FTimes = dbo.FNGetValue(<EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD>Ŀ, '<EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD>')
UPDATE TImpCourse SET FRemainTimes = dbo.FNGetValue(<EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD>Ŀ, 'ʣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
UPDATE TImpCourse SET FRemainAmount =dbo.FNGetValue(<EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD>Ŀ, 'ʣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
UPDATE TImpCourse SET FAdjustPrice =dbo.FNGetValue(<EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD>Ŀ, '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѽ<EFBFBD><EFBFBD><EFBFBD>')
UPDATE TImpCourse SET FExpiredDate = NULL
UPDATE TImpCourse SET FExpiredDate =dbo.FNGetValue(<EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD>Ŀ, 'ʧЧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>') WHERE <EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD>Ŀ LIKE '%ʧЧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%'
UPDATE TImpCourse SET FAmount = ROUND(CAST(FAdjustPrice AS FLOAT) * FTimes ,0)
UPDATE TImpCourse SET FUsedTimes = CAST(FTimes AS FLOAT) - FRemainTimes
SELECT SUBSTRING(<EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD>Ŀ,CHARINDEX('<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:',<EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD>Ŀ) + LEN('<EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD>Ŀ:'), )
SELECT dbo.FNGetValue(<EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD>Ŀ, '<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
FROM TImpCourse
SELECT * FROM TImpCourse WHERE <EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD> IN (SELECT FMobilePhone FROM TMember WHERE FMemNo LIKE '%.2')
UPDATE A
SET A.FItemId = B.FId,
A.FCourseId = C.FId
FROM TImpCourse AS A,TItem AS B,TCourse AS C
WHERE A.FItemNo = B.FNo
AND B.FId =C.FItemId
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ
SELECT FItemNo ,FItemName
FROM TImpCourse
GROUP BY FItemNo ,FItemName
INSERT TItem(FId,FNo,FNoOfPad,FName,FAbbr,FTypeId,FBriefCode,FDescription,FPriceMode,FIsService,FStatTimes,FCustom1,FCustom2,FCustom3,FEnabled,FPrice,FVipPrice,FTime,FDctId,FPointMode,FPointValue,FDeptId,FAllowBooking)
SELECT dbo.FNNewId(),FItemNo,FItemNo,FItemName,FItemName,0,dbo.FNGetFirstPinYin(FItemName),'''',1,1,1,'''','''','''',1,0,0,0,0,1,0,0,1
FROM TImpCourse
GROUP BY FItemNo ,FItemName
INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode)
SELECT dbo.FNNewId() AS FId,
I.FNo + 'L1' AS FNo,
I.FName + '-' + '<EFBFBD>Ƴ<EFBFBD>1' AS FName,
'' AS FBriefCode,
I.FId AS FItemId,
0 AS FPackId,
1 AS FSequence,
0 AS FTypeId,
1 AS FTimes,
0 AS FFreeTimes,
0 AS FDurable,
0 AS FValidityPeriodUnit,
0 AS FValidityPeriod,
getdate() AS FCreateDate,
NULL AS FExpiredDate,
'''' AS FDescription,
1 AS FEnabled,
I.FPrice AS FPrice,
I.FPrice AS FAmount,
1 AS FCalcMode
FROM TItem AS I
---
INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FPurAmount,FUsedPurTimes,FFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice)
SELECT FCardId,FMemId,FCourseId,0,FItemId,FCompId,FTimes,FAmount,FUsedTimes,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'<EFBFBD><EFBFBD>ʢ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',2,0
FROM TImpCourse
update TMemberCOurse SET FExpiredDate = '9999-01-01'
UPDATE TMemberCourse SET FCalcMode = 1
SELECT * FROM TImpCourse WHERE FMemId = 41415488
SELECT * FROM TImpCourse WHERE FMemNO = '5919'
SELECT * FROM TMemberCourselOG
INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,
FRemainPurTimes,FRemainFreeTimes,FCompId,
FBillType,FBizType,FBillId,FBillNo,FBillDetailId)
SELECT dbo.FNNewId(),FMemId,FCardId,0,FCourseId,FTime = getdate(),FTimes,0,FUsedTimes,0,
FRemainTimes,0,FCompId,
'DR','Import',0,'',0
FROM TImpCourse
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʷ
SELECT * FROM TImpTransLog
INSERT TMemberOldTransHist(FId,FCompId,FMemId,FTime,FCardId,FBIllType,FBizType,FTransNo,FCOntent,FPrice,FQuantity,FAmount,FPayment,Femployee,FMemo)
SELECT dbo.FNNewId(),1,FMemId,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>,0,'','',ISNULL(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,'') AS FTransNo,
ISNULL(<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD>Ʒ,''),0,1,0,ISNULL(<EFBFBD><EFBFBD><EFBFBD>ѽ<EFBFBD><EFBFBD><EFBFBD>,''),'', '' AS FMemo
FROM TImpTransLog
WHERE FMemId IS NOT NULL
AND FMemId IN(SELECT FMemId FROM TImpMember3)