SELECT count(1) FROM card use qingdao_qiliya SELECT LEN('20:10-20:22,20:20-20:20') SELECT HT_CARD_FILE.DANH, HT_CARD_FILE.KBMH, HT_CARD_FILE.KZT, HT_CARD_FILE.KLXBM, HT_CARD_FILE.SFXQ, HT_CARD_FILE.XQSJ, HT_CARD_FILE.FKDD, HT_CARD_FILE.FKRY, HT_CARD_FILE.FKSJ, HT_CARD_FILE.SKRY, HT_CARD_FILE.SKSJ, HT_CARD_FILE.BKSJ, HT_CARD_FILE.BKRY, HT_CARD_FILE.BZ, HT_CARD_FILE.SBM, VIEW_card_yue_find_yue.充值金额 as 充值金额, VIEW_card_yue_find_yue.消费金额 as 消费金额, ht_card_file.XM as 'xm', ht_card_file.LSDH as 'lsdh', ht_card_file.SFZ as 'sfz', HT_CARD_FILE.kyxq INTO TImpMember FROM QingDao_QiLiYa_..HT_CARD_FILE LEFT OUTER JOIN QingDao_QiLiYa_..VIEW_card_yue_find_yue ON HT_CARD_FILE.DANH = VIEW_card_yue_find_yue.档案号 where ht_card_file.danh like '%' and ht_card_file.kzt like '%' and ht_card_file.klxbm like '%' SELECT * FROM TImpMember select * from QingDao_QiLiYa_..HT_CARD_FILE SELECT *INTO TImpCardType FROM QingDao_QiLiYa_..ht_card_type ALTER TABLE TImpCardType ADD FId BIGINT ALTER TABLE TImpCardType ADD FItemId BIGINT UPDATE TImpCardType SET FId = dbo.FNNewId() UPDATE TImpCardType SET FItemId = dbo.FNNewId() ALTER TABLE TImpMember ADD FMemId BIGINT ALTER TABLE TImpMember ADD FMemNo VARCHAR(50) ALTER TABLE TImpMember ADD FCardTypeId BIGINT ALTER TABLE TImpMember ADD FItemId BIGINT ALTER TABLE TImpMember ADD FName VARCHAR(50) ALTER TABLE TImpMember ADD FMobile VARCHAR(50) ALTER TABLE TImpMember ADD FMemo VARCHAR(1000) ALTER TABLE TImpMember ALTER COLUMN FMemo VARCHAR(8000) ALTER TABLE TImpMember ADD FBirthday DATETIME ALTER TABLE TImpMember ADD FCreateDate DATETIME ALTER TABLE TImpMember ADD FIsCourse BIT ALTER TABLE TImpMember ADD FCompId BIGINT ALTER TABLE TImpMember ADD FBirhtday DATETIME ALTER TABLE TImpMember ADD FPW VARCHAR(50) ALTER TABLE TImpMember ADD FGender INT ALTER TABLE TImpMember ADD FBriefCode VARCHAR(50) ALTER TABLE TImpMember ADD FExpiredDate VARCHAR(100) ALTER TABLE TImpMember ADD FBalance DECIMAL(18,6) ALTER TABLE TImpMember ADD FRemainTimes DECIMAL(18,6) ALTER TABLE TImpMember ADD FCardId BIGINT ALTER TABLE TImpMember ADD FCardState INT ALTER TABLE TImpMember ADD FCalcMode INT ALTER TABLE TImpMember ADD FValueType INT ALTER TABLE TImpMember ADD FDeleted INT SELECT * FROM TImpMember 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,LXMC,LXMC,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 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 = dbo.FNCompId('001') AND NOT EXISTS(SELECT TOP 1 1 FROM TMemberCardTypeSub AS B WHERE B.FCompId = C.FId AND B.FCardTypeId = I.FId) 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 FItemId,LXMC,LXMC,LXMC,LXMC,0,dbo.FNGetFirstPinYin(LXMC),'',1,1,1,'','','',1,0,0,0,0,0,0,0,1 FROM TImpCardType WHERE LXMC IN('无虑剪发') 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 AS FId, A.LXMC + 'L1', A.LXMC AS FItemName, '' AS FBriefCode, A.FItemId AS FItemId, 0 AS FPackId, 1 AS FSequence, (SELECT TOP 1 FId FROM TBasicType WHERE FKey = 'CourseType') 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, 0 AS FPrice, 0 AS FAmount, 1 AS FCalcMode FROM TImpCardType AS A WHERE LXMC IN('无虑剪发') SELECT * FROM TImpMember UPDATE TImpMember SET FMemId = dbo.FNNewId() WHERE FMemId IS NULL UPDATE TImpMember SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL UPDATE TImpMember SET FName = xm, FGender = 0, FMobile = ISNULL(lsdh,''), FMemNo = DANH, FCreateDate = SKSJ, FExpiredDate = ISNULL(kyxq, DATEADD(YEAR,100,SKSJ)), FBalance= 充值金额-消费金额, FPW = '', FMemo = ISNULL(bz,''), FCardState = 1, FCompId = dbo.FNCompId('001') UPDATE TImpMember SET FCardState = 1 WHERE KZT = '售出' UPDATE TImpMember SET FCardState = 4 WHERE KZT = '挂失' UPDATE TImpMember SET FCardState = 5 WHERE KZT = '禁用' UPDATE TImpMember SET FDeleted = 0 UPDATE TImpMember SET FDeleted = 0 WHERE KZT ='发卡' SELECT KZT FROM TImpMember GROUP BY KZT SELECT * FROM TImpMember SELECT * FROM TImpCardType WHERE LXBM NOT IN(SELECT KLXBM FROM TImpMember) SELECT * FROM TImpMember DELETE TMemberCardType WHERE FId = 7084890207791266836 UPDATE A SET A.FCardTypeId = B.FId,FValueType=1,FItemId = B.FItemId FROM TImpMember AS A,TImpCardType AS B WHERE A.KLXBM = b.lxbm PClearMemberDat UPDATE TImpMember SET FCreateDate = '1900-01-01' WHERE FCreateDate IS NULL AND FDeleted = 0 UPDATE TImpMember SET FExpiredDate = DATEADD(YEAR,100,FCreateDate) WHERE FExpiredDate IS NULL --插入会员 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, FMemNo, FName, dbo.FNGetFirstPinYin(FName), 0 AS FTypeId, FCompId, FCreateDate, FGender, 'G' AS FBirthdayType, FBirthday, '' AS FTelephone, FMobile, '' AS FQQ, '' AS FWeChat, '' AS FIdCard, '' AS FEmail, '' AS FAddress, 0 AS FProId, ISNULL(FPW,'') AS FCPW, ISNULL(FPW,'') AS FQPW, 0 AS FChargeEmpId, 0 AS FPoint, 1 AS FRecvConsSMS, 1 AS FRecvBulkSMS, '', '' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5 from TImpMember WHERE FDeleted = 0 INSERT INTO dbo.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, FValueType, FCompId AS FCompId, FMemId AS FMemId, FCardState AS FState, FCreateDate AS FCreateDate, FExpiredDate AS FExpiredDate, ISNULL(FRemainTimes,0) AS FTotalTimes, 0 AS FUsedTimes, 0 AS FSaleCompId, 0 AS FSaleBillId, FMemo AS FMemo FROM TImpMember WHERE FDeleted = 0 AND FIsCourse = 0 INSERT TMemberCardAccount(FId,FMemId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo) SELECT dbo.FNNewId(),FMemId,FCardId AS FCardId,3,ISNULL(FBalance,0),ISNULL(FBalance,0),0,FCreateDate,NULL,'' FROM TImpMember WHERE FDeleted = 0 AND FIsCourse = 0 INSERT dbo.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,'',ISNULL(A.FBalance,0),0,ISNULL(A.FBalance,0),0,getdate(),'' from TImpMember AS A WHERE FDeleted = 0 AND FIsCourse = 0 UPDATE TImpMember SET FIsCourse = 0 UPDATE TImpMember SET FIsCourse = 1 WHERE FCardTypeId IN(SELECT FId FROM TCourse) UPDATE TImpMember SET FCalcMode = 2 INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FUsedPurTimes,FPurAmount,FFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice) SELECT FCardId,FMemId,FCardTypeId,0,FItemId,FCompId,0,0,0,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'导入',FCalcMode,0 FROM TImpMember AS A WHERE FIsCourse = 1 AND FDeleted = 0 INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,FCompId,FBillType,FBizType,FBillId,FBillNo,FBillDetailId,FRecordTime) SELECT dbo.FNNewId(),FMemId,A.FCardId AS FCardId,0, ISNULL(FCardTypeId,0),getdate(),0,0,0,0,FCompId,'DR','Import',0,'',0,getdate() FROM TImpMember AS A WHERE FIsCourse = 1 AND FDeleted = 0 SELECT * FROM TImpMember WHERE FMemNO = '600215'