SELECT * FROM TImpMember SELECT * FROM TImpMember ORDER BY 会员卡号 WHERE CUSTNO NOT IN (SELECT CUSTNO FROM TImpMember) INSERT INTO TMemberCardType(FId,FNo,FName,FValueType,FMaterial,FPrice,FCardFeeAmt,FAcctId,FDeposit,FAcctId2,FDeposit2, FAcctId3,FDeposit3,FTimes,FAlertBalance,FPaySmsFee,FTimeCard,FValidityPeriod,FValidityPeriodUnit,FExpiredDate, FDefaultMemo,FCreateTime,FAllowSale,FAllowRchg,FEnabled,FOrder,FDeptId) SELECT dbo.FNNewId() AS FId,FCardTypeName AS FNo,FCardTypeName AS FName,1 AS ValueType,1 AS FMaterial,0 AS FPrice,0 AS FCardFeeAmt,0 AS FAcctId,0 AS FDeposit,0 AS FAcctId2,0 AS FDeposit2,0 AS FAcctId3,0 AS FDeposit3,0 AS FTimes,0 AS FAlertBalance,0 AS FPaySmsFee,0 AS FTimeCard,0 AS FValidityPeriod,0 AS FValidityPeriodUnit,'' AS FExpiredDate,'' AS FDefaultMemo,'' AS FCreateTime,0 AS FAllowSale,0 AS FAllowRchg,1 AS FEnabled,0 AS FOrder,0 AS FDeptId FROM TImpMember GROUP BY FCardTypeName SELECT * FROM TMemberCardType UPDATE TMemberCardType SET FSalePointValue = 0,FRchgPointValue = 0 ,FAllowSale=1,FAllowRchg = 1,FMaterial = 2 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 FDeposit DECIMAL(18,6) 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 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 FTotalTimes INT ALTER TABLE TImpMember ADD FUsedTimes INT ALTER TABLE TImpMember ADD FDeleted BIT ALTER TABLE TImpMember ADD FState INT DELETE TImpMember WHERE 卡类型= '非会员散客' OR 会员卡号 = '合计:' SELECT * FROM TImpMember WHERE 卡类型= '非会员散客' OR 会员卡号 IS NULL OR 会员卡号 = '合计:' UPDATE TImpMember SET FMemId = dbo.FNNewId() WHERE FMemid IS NULL UPDATE TImpMember SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL UPDATE TImpMember SET FMemNo = 会员卡号 UPDATE TImpMember SET FCardNo = 会员卡号 UPDATE TImpMember SET FMemo = 地址 + ' ' + 喜好 UPDATE TImpMember SET FCreateDate = 办卡日期 UPDATE TImpMember SET FExpiredDate = 有效期至 UPDATE TImpMember SET FExpiredDate =DATEADD(YEAR,1000,办卡日期) WHERE FExpiredDate IS NULL UPDATE TImpMember SET FGender = 0 UPDATE TImpMember SET FMobile = 电话 UPDATE TImpMember SET FName = 会员姓名 UPDATE TImpMember SET FMobile = left(电话,11) WHERE LEN(电话) > 20 UPDATE TImpMember SET FBalance = 储值卡余额 UPDATE TImpMember SET FBirthday = 会员生日 UPDATE TImpMember SET FMemNo = FName,FCardNO = FName WHERE FMemNo = '' UPDATE TImpMember SET FCardTypeId = (SELECT FId FROM TMemberCardType WHERE FName = '1000元7折卡') WHERE 卡类型= '1000' UPDATE TImpMember SET FCardTypeId = (SELECT FId FROM TMemberCardType WHERE FName = '500元8折卡') WHERE 卡类型= '500' UPDATE TImpMember SET FCardTypeId = (SELECT FId FROM TMemberCardType WHERE FName = '300元8折剪发卡') WHERE 卡类型= '300' UPDATE TImpMember SET FCardTypeId = (SELECT FId FROM TMemberCardType WHERE FName = '2000元6折卡') WHERE 卡类型= '2000' UPDATE TImpMember SET FCardTypeId = (SELECT FId FROM TMemberCardType WHERE FName = '3000元5.5折') WHERE 卡类型= '3000' UPDATE TImpMember SET FCardTypeId = (SELECT FId FROM TMemberCardType WHERE FName = '9800元5折卡') WHERE 卡类型= '9800' UPDATE TImpMember SET FCardTypeId = (SELECT FId FROM TMemberCardType WHERE FName = '7000') WHERE 卡类型= '7000' UPDATE TImpMember SET FCardTypeId = (SELECT FId FROM TMemberCardType WHERE FName = '4200') WHERE 卡类型= '4200' UPDATE TImpMember SET FCardTypeId = (SELECT FId FROM TMemberCardType WHERE FName = '1300') WHERE 卡类型= '1300' UPDATE TImpMember SET FCardTypeId = (SELECT FId FROM TMemberCardType WHERE FName = '800') WHERE 卡类型= '800' UPDATE TImpMember SET FCardTypeId = (SELECT FId FROM TMemberCardType WHERE FName = '400') WHERE 卡类型= '400' UPDATE TImpMember SET FCardTypeId = (SELECT FId FROM TMemberCardType WHERE FName = '2800') WHERE 卡类型= '2800' SELECT * FROM TImpMember WHERE FCardTypeId IS NULL SELECT * FROM TMemberCardType UPDATE T SELECT FMemNo ,SUM(1) FROM TImpMember GROUP BY FMemNO ORDER BY SUM(1) DESC UPDATE TImpMember SET FGender = 0 UPDATE TImpMember SET FExpiredDate = DATEADD(YEAR,100,FCreateDate) SELECT * FROM TImpMember DROP TABLE TImpMember UPDATE TMember SET FMemo = '' 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, ISNULL(ISNULL(FName,FMobile),FMemNo) AS FName, dbo.FNGetFirstPinYin(FName), 0 AS FTypeId, 1 AS FCompId, FCreateDate AS FCreateDate, FGender AS FGender, 'G' 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(FMemo,'') AS FMemo, '' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5 from TImpMember SELECT * FROM TImpMember WHERE LEN(FMobile) > 20 INSERT INTO TMemberCard( FCardId, FCardNo, FCardFaceNo, FTypeId, FValueType, FCompId, FMemId, FState, FCreateDate, FExpiredDate, FTotalTimes, FUsedTimes, FSaleCompId, FSaleBillId, FMemo,FDeleted) 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, FExpiredDate, 0 AS FTotalTimes, 0 AS FUsedTimes, 1 AS FSaleCompId, 0 AS FSaleBillId, FMemo AS FMemo,0 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 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,1,'DR','Import',0,'',A.FBalance,0,A.FBalance,0,getdate(),'从老系统中导入' FROM TImpMember AS A SELECT * FROM TImpTransLog WHERE 客户编号 = 'A020935' update A SET A.FMemId SELECT * FROM TMemberCard WHERE FId = 5494058162892437466 UPDATE A SET A.FExpiredDate = B.FExpiredDate FROM TMemberCard AS A,TImpMember AS B WHERE A.FCardId = B.FCardId SELECT * FROM TImpMember UPDATE A SET A.FMemo = B.Rem FROM TMemberCard AS A,TImpMember AS B WHERE A.FCardId = B.FCardId AND B.Rem IS NOT NULL SELECT * FROM TMemberCardType UPDATE TMemberCardType SET FId = FNo + 1000 WHERE FId > 0 UPDATE TMemberCard SET FTypeId = 0 DELETE TMemberCardTypeSUB UPDATE A SET A.FTypeId = B.CType + 1000 FROM TMemberCard AS A,TImpMember AS B WHERE A.FCardId = B.FCardId UPDATE TImpMember SET FCardTypeId = CType + 1000 SELECT * FROM TMemberCard WHERE FMemo != '' delete TImpMember where CUSTNO IN(SELECT CUSTNO FROM TImpMember2)