select * from TMemberCardType SELECT * FROM TImpMember SELECT * INTO TImpMember FROM WuHan_TangFengCai_ST..g_G SELECT * INTO TImpMemberCard FROM WuHan_TangFengCai_ST..g_GAcc SELECT * INTO TImpCardType FROM WuHan_TangFengCai_ST..g_C SELECT * INTO TImpCardNo FROM WuHan_TangFengCai_ST.dbo.g_GCard SELECT * FROM TMemberCardType SELECT * FROM TImpCardType SELECT * FROM TImpCardType --类别 ALTER TABLE TImpCardType ADD FId BIGINT UPDATE TImpCardType SET FId = 10000 + CaId DELETE TMemberCardTypeSub DELETE TMemberCardType WHERE FId > 10 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 =FId, CaId,CaName name,1,FMaterial = 2,MSale,FCardFeeAmt = 0,FAcctId = 3,FDeposit = MAcc,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 1=1 AND (Del = 0 OR CAID IN(SELECT CaId FROM TImpMemberCard WHERE Del = 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 --会员 ALTER TABLE TImpMember ADD FMemId BIGINT ALTER TABLE TImpMember ADD FCardId BIGINT ALTER TABLE TImpMember ADD FCardTypeName VARCHAR(100) 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 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 FDeleted BIT ALTER TABLE TImpMember ADD FCreateDate DATETIME ALTER TABLE TImpMember ADD FMemo VARCHAR(500) ALTER TABLE TImpMember ADD FPoint DECIMAL(18,6) ALTER TABLE TImpMemberCard ADD FCardId BIGINT ALTER TABLE TImpMemberCard ADD FMemId BIGINT ALTER TABLE TImpMemberCard ADD FCompId BIGINT ALTER TABLE TImpMemberCard ADD FCardState INT ALTER TABLE TImpMemberCard ADD FCardTypeId BIGINT ALTER TABLE TImpMemberCard ADD FCreateDate DATETIME ALTER TABLE TImpMemberCard ADD FExpiredDate DATETIME ALTER TABLE TImpMemberCard ADD FMemo VARCHAR(MAX) ALTER TABLE TImpMemberCard ADD FBalance DECIMAL(18,6) ALTER TABLE TImpMemberCard ADD FBalance2 DECIMAL(18,6) ALTER TABLE TImpMemberCard ADD FDeleted BIT ALTER TABLE TImpMemberCard ADD FCardNo VARCHAR(50) SELECT * FROM TIMpMember SELECT * FROM TIMpMemberCard --会员ID UPDATE TImpMember SET FMemId = 10000 + GId --姓名 UPDATE TImpMember SET FName = GName --电话 UPDATE TImpMember SET FMobile = '' --性别 UPDATE TImpMember SET FGender = CASE WHEN GSex = 1 THEN 1 ELSE 0 END --日期 UPDATE TImpMember SET FCreateDate = RegTime --删除 UPDATE TImpMember SET FDeleted = Del --备注 UPDATE TImpMember SET FMemo = Remark --门店 UPDATE TImpMember SET FCompId = 1 --生日 UPDATE TImpMember SET FBirthday = NULL UPDATE A SET A.FBirthday = '9999' + SDAY FROM TImpMember AS A,WuHan_TangFengCai_ST..G_GDay AS B WHERE A.Gid = B.GId AND B.Del= 0 UPDATE TImpMember SET FBirthdayType = 'G' --积分 UPDATE A SET A.FPoint = B.InInt FROM TImpMember AS A,WuHan_TangFengCai_ST..G_GInt AS B WHERE A.GID = B.GID SELECT * FROM TImpMember UPDATE A SET A.FBirthday = B.FBirthday FROM TMember AS A,TImpMember AS B WHERE A.FMemId = B.FMemId SELECT * FROM TImpMember WHERE FName = '佟克畏' SELECT * FROM TImpMemberCard WHERE gid = 288 --卡号 UPDATE A SET A.FMemNo = B.CardNum FROM TImpMember AS A,TImpCardNo AS B WHERE A.GId = B.GId UPDATE TImpMember SET FMemNO = FName WHERE FMemNO IS NULL AND FDeleted = 0 SELECT FMemNO ,SUM(1) FROM TImpMember GROUP BY FMemNO HAVING(SUM(1) > 1) SELECT * FROM TImpMember WHERE FMemNO = '600068' --卡ID UPDATE TImpMemberCard SET FCardId = 10000 + AccId --卡号,会员Id UPDATE A SET A.FCardNo = B.FMemNo, A.FMemId = B.FMemId FROM TImpMemberCard AS A,TImpMember AS B WHERE A.GId = B.GId --卡类别ID UPDATE A SET A.FCardTypeId = B.FId FROM TImpMemberCard AS A,TImpCardType AS B WHERE A.CaId = B.CaId --创建时间 UPDATE TImpMemberCard SET FCreateDate = RegTime --有效期 UPDATE TImpMemberCard SET FExpiredDate = ISNULL(EndTime,DATEADD(YEAR,100,FCreatedATE)) --余额 UPDATE TImpMemberCard SET FBalance = AccM --已删 UPDATE TImpMemberCard SET FDeleted = Del --门店 UPDATE TImpMemberCard SET FCompId = 1 --状态 UPDATE TImpMemberCard SET FCardState = 1 SELECT * FROM TImpMemberCard 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 ,GETDATE()) 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, FMemo AS FMemo, '' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5 from TImpMember WHERE FDeleted = 0 INSERT TMemberPointHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FMemo,FRecordTime) SELECT dbo.FNNewId(),A.FMemId,getdate(),0,1,'DR','Import',0,'',FPoint,0,FPoint,'',getdate() FROM TImpMember AS A WHERE FPoint != 0 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, FExpiredDate = ISNULL(FExpiredDate,DATEADD(YEAR,100,FCreateDate)), 0 AS FTotalTimes, 0 AS FUsedTimes, FCompId AS FSaleCompId, 0 AS FSaleBillId, '' AS FMemo FROM TImpMemberCard WHERE FDeleted = 0 AND FMemId IN(SELECT FMemId FROM TMember) 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 TImpMemberCard WHERE FDeleted = 0 AND FCardId IN(SELECT FCardId FROM TMemberCard) 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 TImpMemberCard AS A WHERE FDeleted = 0 AND FCardId IN(SELECT FCardId FROM TMemberCard) --疗程 ALTER TABLE TimpMemberCourse ADD FSeq INT IDENTITY DROP TABLE #Seq UPDATE A SET A.序号 = B.序号 FROM TImpMemberCourse AS A,TImpMemberCourse AS B,(SELECT FSeq FROM TImpMemberCourse WHERE 序号 IS NULL) AS C WHERE A.FSeq = C.FSeq AND B.FSeq = C.FSeq - 1 SELECT * FROM TImpMemberCourse UPDATE A SET A.姓名 = B.姓名, A.性别 = B.性别 FROM TImpMemberCourse AS A,TImpMemberCourse AS B WHERE A.序号 = B.序号 AND A.姓名 IS NULL AND B.姓名 IS NOT NULL ALTER TABLE TIMpMemberCourse ADD FPurTimes INT ALTER TABLE TIMpMemberCourse ADD FUsedPurTimes INT ALTER TABLE TIMpMemberCourse ADD FPurAmount DECIMAL(18,6) ALTER TABLE TIMpMemberCourse ADD FItemId BIGINT ALTER TABLE TIMpMemberCourse ADD FCourseId BIGINT ALTER TABLE TIMpMemberCourse ADD FCreateDate DATETIME ALTER TABLE TIMpMemberCourse ADD FExpiredDate DATETIME ALTER TABLE TIMpMemberCourse ADD FCompId BIGINT ALTER TABLE TIMpMemberCourse ADD FMemId BIGINT ALTER TABLE TIMpMemberCourse ADD FCardId BIGINT ALTER TABLE TIMpMemberCourse ADD FCourseId BIGINT UPDATE TImpMemberCOurse SET FCompId = 1 UPDATE TImpMemberCOurse SET FCardId = dbo.FNNewId() UPDATE A SET A.FMemId = B.FMemId FROM TImpMemberCourse AS A,TImpMember AS B WHERE A.姓名= B.FName UPDATE A SET A.FCreateDate = B.FCreateDate FROM TImpMemberCourse AS A,TImpMember AS B WHERE A.FMemId = B.FMemId UPDATE A SET A.FItemId = B.FItemId, A.FCourseId = B.FId FROM TImpMemberCourse AS A,TCourse AS B WHERE A.名称 = B.FNAME SELECT * FROM TImpMemberCourse 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,FCourseId,0,FItemId,FCompId,FPurTimes,0,0,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'赛腾导入',1,0 FROM TImpMemberCourse AS A 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(FCourseId,0),getdate(),FPurTimes + 0,0,0,0,FCompId,'DR','Import',0,'',0,getdate() FROM TImpMemberCourse AS A 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(),名称,名称,名称,名称,0,dbo.FNGetFirstPinYin(名称),'',1,1,1,'','','',1,0,0,0,0,1,0,0,1 FROM TImpMemberCourse GROUP BY 名称 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 AS FNo, I.FName 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 WHERE FNo IN(SELECT 名称 FROM TImpMemberCourse) SELECT 名称 FROM TImpMemberCourse GROUP BY 名称 UPDATE TImpMemberCourse SET FPurTimes = 次数 DROP TABLE TImpMemberCourse