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/丝美/SQLQuery14.sql

365 lines
12 KiB

Host: vip6.minicon.net
Cookie: pgv_pvi=9312305152; _qddaz=QD.goi4zv.78oeij.j0rp9yle; tencentSig=4360550400; __utma=188988972.89303666.1493440836.1493440836.1493440836.1; __utmz=188988972.1493440836.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); FaYiMIS=C3260D87C65A6CD898E66F109DA566E69BB907FD4FF4ECCA0DB1E4BE435526321DD9312A23BD2EFC4DDDB403FB26D87E7377F9CA013E43619588813A314EDC8018A941A00EBA44EE63EAAC9BE117ADC6CE0DB8292A5EA5ADE6BCD165E18FD3F4B59E715EA961188189097440616F35BEF700BFADE29893C2DBF96A0453E78756; findMemberMode=1; _qdda=3-1.3fxd57; _qddab=3-gh722w.j22y6q62; _qddamta_4000921365=3-0
Host: vip6.minicon.net
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0
Accept-Encoding: gzip, deflate
Cookie: pgv_pvi=9312305152; _qddaz=QD.goi4zv.78oeij.j0rp9yle; tencentSig=4360550400; __utma=188988972.89303666.1493440836.1493440836.1493440836.1; __utmz=188988972.1493440836.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); FaYiMIS=C3260D87C65A6CD898E66F109DA566E69BB907FD4FF4ECCA0DB1E4BE435526321DD9312A23BD2EFC4DDDB403FB26D87E7377F9CA013E43619588813A314EDC8018A941A00EBA44EE63EAAC9BE117ADC6CE0DB8292A5EA5ADE6BCD165E18FD3F4B59E715EA961188189097440616F35BEF700BFADE29893C2DBF96A0453E78756; findMemberMode=1; _qdda=3-1.3fxd57; _qddab=3-gh722w.j22y6q62; _qddamta_4000921365=3-0
a=GetMemberCiKaList&mid=5903110&ts=0.44291844694142035
SELECT * FROM TImpMemberCourse
delete TImpMemberCourse
drop table TImpMemberCourse
ALTER TABLE TImpMember ADD FMemId BIGINT
ALTER TABLE TImpMember ADD FMemId BIGINT
SELECT * FROM TImpMember
--»áÔ±
ALTER TABLE TImpMember ADD FMemId BIGINT
ALTER TABLE TImpMember ADD FCardTypeName VARCHAR(100)
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 FBirthdayType VARCHAR(50)
ALTER TABLE TImpMember ADD FBirthday DATETIME
ALTER TABLE TImpMember ADD FCompId BIGINT
ALTER TABLE TImpMember ADD FCardTypeId BIGINT
ALTER TABLE TImpMember ADD FCreateDate DATETIME
ALTER TABLE TImpMember ADD FExpiredDate DATETIME
ALTER TABLE TImpMember ADD FMemo VARCHAR(MAX)
ALTER TABLE TImpMember ADD FBalance DECIMAL(18,6)
SELECT * FROM TImpMember
UPDATE A
SET A.FMemNo = A.»áÔ±¿¨ºÅ
FROM TImpMember AS A
UPDATE TImpMember SET FMobile = ÊÖ»úºÅÂë
UPDATE TImpMember SET FName = »áÔ±ÐÕÃû
UPDATE TImpMember SET FBalance = cast(Óàî as float)
UPDATE TImpMember SET FBirthdayType = ''
UPDATE TImpMember SET FMemo = ''
UPDATE A
SET A.FCreateDate = '1900-01-01',
A.FExpiredDate = '9000-01-01'
FROM TImpMember AS A
UPDATE TI
UPDATE TImpMember SET FGender = 0
UPDATE TImpMember SET FCardTypeName = »áÔ±¿¨Ãû³Æ
SELECT FCardTypeName FROM TImpMember
GROUP BY FCardTypeName
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 = dbo.FNNewId(),»áÔ±¿¨Ãû³Æ,»áÔ±¿¨Ãû³Æ,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 TImpMember
GROUP BY »áÔ±¿¨Ãû³Æ
UPDATE A
SET A.FCardTypeId = B.FId
FROM TImpMember AS A,TMemberCardType AS B
WHERE A.»áÔ±¿¨Ãû³Æ= B.FName
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 TImpMember
ALTER TABLE TImpMember ADD FCardId BIGINT
UPDATE TImpMember SET FCardId = dbo.FNNewId()
INSERT INTO TMemberCard(
FCardId,
FCardNo,
FTypeId,
FValueType,
FCompId,
FMemId,
FState,
FCreateDate,
FExpiredDate,
FTotalTimes,
FUsedTimes,
FSaleCompId,
FSaleBillId,
FMemo)
SELECT
FCardId AS FId,
FMemNo 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
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
WHERE FCardId NOT IN(SELECT FCardId FROM TMemberCardAccount)
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(),'´ÓÀÏϵͳÖе¼Èë'
FROM TImpMember AS A
WHERE FCardId NOT IN(SELECT FCardId FROM TMemberCardAccount)
UPDATE TImpMember SET FCompId = 1
SELECT * FROM TImpMember
drop table #cARD
SELECT FMemNo,sum(1)cnt
into #Card
FROM TImpMember
GROUP BY FMemNo
having(sum(1) > 1)
UPDATE TImpMember SET FMemNO = »áÔ±¿¨ºÅ
UPDATE TImpMember
SET FMemNo = FMobile WHERE FMemNo IN(SELECT FMemNo FROM #Card)
UPDATE TImpMember
SET FMemNo = »áÔ±¿¨ºÅ WHERE FMemNo IN(SELECT FMemNo FROM #Card)
AND FMobile = ''
SELECT * FROM TImpMember WHERE FMemNo IN( SELECT FMemNo FROM #Card)
ORDER BY FMemNo
SELECT * FROM TImpMember10
where ³Ö¿¨Êý > 1
SELECT COUNT(1) FROM TImpMember WHERE FCourses IS NULL
DELETE TImpMemberCourse
UPDATE TImpMember SET FCOurses = NULL
SELECT * FROM TImpMember
where ÕÕƬ is null
DELETE TImpMember
--¿¨
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 count(1) FROM
TImpMemberCourse
SELECT * FROM TImpMember WHERE FCourses IS NULL
INSERT TItem(FId,FNo,FNoOfPad,FName,FAbbr,FTypeId,FBriefCode,FDescription,FPriceMode,FIsService,FStatTimes,FCustom1,FCustom2,FCustom3,FEnabled,FPrice,FVipPrice,FTime,FDctId,FDisplayTypeId,FPointMode,FPointValue,FDeptId,FAllowBooking)
SELECT dbo.FNNewId(),Item,Item,Item,Item,0,FBriefCode = dbo.FNGetFirstPinYin(Item),
FDescription = '',FPriceMode = 0,FIsService = 1,FStatTimes = 1,FCustom1 = '',FCustom2 = '',
FCustom3 = '',FEnabled = 1,0 ,FVipPrice = 0 ,FTime = 0,FDctId = 0 ,FDisplayTypeId = 0,
FPointMode = 0,FPointValue = 0,FDeptId = 0,FAllowBooking = 1
FROM TImpMemberCourse
WHERE Item NOT IN(SELECT FName FROM TItem)
GROUP BY Item
ALTER TABLE TItem ALTER COLUMN FNo VARCHAR(1000) NOT NULL
ALTER TABLE TItem ALTER COLUMN FAbbr VARCHAR(1000) NOT NULL
ALTER TABLE TItem ALTER COLUMN FName VARCHAR(1000) NOT NULL
ALTER TABLE TItem ALTER COLUMN FNoOfPad VARCHAR(1000) NOT NULL
ALTER TABLE TItem ALTER COLUMN fbRIEFcODE VARCHAR(1000) NOT NULL
ALTER TABLE TCourse ALTER COLUMN FNo VARCHAR(1000) NOT NULL
ALTER TABLE TCourse ALTER COLUMN FAbbr VARCHAR(1000) NOT NULL
ALTER TABLE TCourse ALTER COLUMN FName VARCHAR(1000) NOT NULL
ALTER TABLE TCourse ALTER COLUMN FNoOfPad VARCHAR(1000) NOT NULL
ALTER TABLE TCourse ALTER COLUMN fbRIEFcODE VARCHAR(1000) NOT NULL
INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode)
SELECT FId = dbo.FNNewId(),
FNo +'L1' AS FNo,
FName AS FName,
'' AS FBriefCode,
FId AS FItemId,
0 AS FPackId,
1 AS FSequence,
0 AS FTypeId,
CAST( 0 AS FLOAT) 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,
0 ,
0 AS FAmount,
1 AS FCalcMode
FROM TItem AS I
WHERE FNo IN(SELECT Item FROM TImpMemberCourse)
AND FNo NOT IN(SELECT FNo FROM TCourse)
SELECT * FROM TImpMember
WHERE FCourses IS NULL
UPDATE TImpMemberCourse SET FCreateDate = '1900-01-01'
UPDATE TImpMemberCourse SET FExpiredDate = NULL
UPDATE TImpMemberCourse SET FExpiredDate = invaliddate
WHERE invaliddate != '1900-01-01'
UPDATE TImpMemberCourse SET FCompId = 1
UPDATE TImpMemberCourse SET FCalcMode = 1
UPDATE TImpMemberCourse SET FCalcMode = 2 WHERE count = '²»ÏÞ'
UPDATE TImpMemberCourse SET FRemainTimes = 0
UPDATE TImpMemberCourse SET FRemainTimes = count WHERE count != '²»ÏÞ'
UPDATE TImpMemberCourse SET FCardId = id
UPDATE A
SET A.FCardTypeId = C.FId,
A.FItemId = C.FItemId
FROM TImpMemberCourse AS A,TCourse AS C,TItem AS I
WHERE A.Item = I.FName
AND I.FId = C.FItemId
UPDATE TImpMemberCourse SET FBalance = 0
UPDATE TImpMemberCourse SET FState = 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,'ÀÏϵͳµ¼Èë',FCalcMode,0,FState
FROM TImpMemberCourse AS A
-- AND ÌײÍÃû³Æ LIKE '%¿Ë%'
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 = ²Ù×÷ʱ¼ä,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 = 'ÀÏϵͳµ¼Èë',FEmployees
FROM TImpMemberCourseHist AS A
WHERE FCardId IN(SELECT FId FROM TMemberCourse)