SELECT LXMC00 FROM TImpMember WHERE 次数 IS NULL GROUP BY LXMC00 SELECT * FROM TImpMember WHERE 次数 IS NULL AND LXMC00 = '百+百头皮保养(去屑)套盒宝' DROP TABLE TImpMember EXEC SP_RENAME 'TImpMember.VIPDJRQ','FCreateDate' EXEC SP_RENAME 'TImpMember.VIPKH00','FCardNo' EXEC SP_RENAME 'TImpMember.KHXM00','FName' EXEC SP_RENAME 'TImpMember.KHXB00','FCreateDate' select * from TImpMember ALTER TABLE TImpMember ADD FMemId BIGINT 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 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 FArrear DECIMAL(18,6) UPDATE TImpMember SET FMemId = dbo.FNNewId() WHERE FMemid IS NULL UPDATE TImpMember SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL UPDATE TImpMember SET FMemNo = VIPKH00 UPDATE TImpMember SET FName = KHXM00 UPDATE TImpMember SET FMobile = KHSJ00 UPDATE TImpMember SET FGender = CASE WHEN KHXB00 = 'M' THEN 1 ELSE '0' END UPDATE TImpMember SET FBalance = 余额 UPDATE TImpMember SET FRemainTimes = 次数 UPDATE TImpMember SET FPurTimes = 次数 UPDATE TImpMember SET FPurAmount = 次数余额 UPDATE TImpMember SET FCreateDate = getdate(); UPDATE TImpMember SET FCompId = 1 UPDATE TImpMember SET FArrear = 欠款 UPDATE A SET A.FCardTypeId = B.FId FROM TImpMember AS A,TMemberCardType AS B WHERE A.LXMC00 = B.FName UPDATE A SET A.FItemId = B.FId FROM TImpMember AS A,TItem AS B WHERE A.LXMC00 = B.FName UPDATE A SET A.FCourseId = B.FId FROM TImpMember AS A,TCourse AS B WHERE A.FItemId = B.FItemId 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, 'G' AS FBirthdayType, NULL 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 INSERT INTO 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 AS FTypeId, (SELECT FValueType FROM TMemberCardType WHERE FId = FCardTypeId) AS FValueType, 1 AS FCompId, FMemId AS FMemId, 1 AS FState, FCreateDate AS FCreateDate, DATEADD(year,1, FCreateDate) AS FExpiredDate, 0 AS FTotalTimes, 0 AS FUsedTimes, FCompId AS FSaleCompId, 0 AS FSaleBillId, '' 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(),'从Excel中导入' 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 FCardId,FMemId,FCourseId,0,FItemId,1,ISNULL(FPurTimes,0),CASE WHEN ISNULL(FPurTimes,0) = 0 THEN 0 ELSE FPurAmount END,0,0,getdate(),null,'DR.Import',0,0,0,'Excel导入',1,0 FROM TImpMember AS A WHERE FCourseId IS NOT NULL 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,FCardId,0,FCourseId,FTime = getdate(),ISNULL(FPurTimes,0),FFreeTimes = 0,0,0, FPurAmount = CASE WHEN ISNULL(FPurAmount,0) = 0 THEN 0 ELSE FPurAmount END,0,0,0,1, 'DR','Import',0,'',0 SELECT * FROM TImpMember WHERE 欠款 > 0 INSERT TMemberArrear(FId,FMemId,FTime,FCompId,FContentType,FCardId,FBillType,FBizType,FTransId,FTransNo,FTransDetailId,FContentId,FArrear,FEmpId,FRepaid,FAcctArrear) SELECT dbo.FNNewId(),A.FMemId,getdate(),A.FCompId,'Account',A.FCardId,'DR_KK','DR_CardSale',0,'',0,0,A.FArrear,0,0,A.FArrear FROM TImpMember AS A WHERE A.FArrear > 0 FROM TImpMember AS A WHERE FCourseId IS NOT NULL SELECT * FROM TMemberOldTransHist ORDER BY FTime DESC UPDATE TMember SET FMemo = FMemo + '这是正鼎中重复的卡, 不要用了',FMemNo = FMemNo + '已删删1',FDeleted = 1 WHERE FMemNo IN(SELECT FMemNo FROM TImpMember) UPDATE A SET A.FMemo = A.FMemo + '这是正鼎中重复的卡, 不要用了', A.FCardNo = B.FMemNo ,A.FCardFaceNo = B.FMemNo,A.FDeleted = 1 FROM TMemberCard AS A,TMember AS B WHERE A.FMemId = B.FMemId AND B.FDeleted = 1 SELECT * FROM TMemberCard UPDATE TMemberCard SET FMemo = REPLACE(FMemo,'这是正鼎中重复的卡, 不要用了',''),FDeleted = 0 WHERE FMemNo IN(SELECT FMemNo FROM TImpMember) SELECT * FROM TMember WHERE FMemNo = '001612046' SELECT * FROM TUser SELECT * FROM TImpMember WHERE FCourseId IS NULL AND FCardTYpeId IS NULL SELECT * FROM TImpMember,TMember WHERE VIPKH00 = FMemNo AND FMobilePhone != KHSJ00 SELECT * FROM TMemb