SELECT * FROM TMember SELECT * FROM TMGWMember WHERE 当前状态 SELECT * FROM TMGWMember WHERE 1=1 --AND 表面号 = '' --AND FDeleted = 0 AND 会员生日!= '1月-1日[公历]' WHERE 当前状态 = '注销' SELECT 当前状态 FROM TMGWMember GROUP BY 当前状态 -- IF OBJECT_ID('TMGWCompany') IS NULL BEGIN CREATE TABLE TMGWCompany ( FCompName VARCHAR(50), FCompNo VARCHAR(50), FCompId BIGINT ) END SELECT FName FROM TCompany SELECT 店面 FROM TMGWMember group by 店面 DELETE TMGWCompany INSERT TMGWCompany(FCompName,FCompNo) SELECT '芒果造型一店','002' INSERT TMGWCompany(FCompName,FCompNo) SELECT '芒果造型二店','003' INSERT TMGWCompany(FCompName,FCompNo) SELECT '芒果造型三店','004' INSERT TMGWCompany(FCompName,FCompNo) SELECT '芒果造型四店','005' UPDATE A SET A.FCompId = B.FId FROM TMGWCompany AS A,TCompany AS B WHERE A.FCompNo = B.FNo -- ALTER TABLE TMGWMember ADD FDeleted BIT ALTER TABLE TMGWMember ADD FState INT ALTER TABLE TMGWMember ADD FMemId BIGINT ALTER TABLE TMGWMember ADD FMemNo VARCHAR(50) ALTER TABLE TMGWMember ADD FName VARCHAR(50) ALTER TABLE TMGWMember ADD FMobilePhone VARCHAR(50) ALTER TABLE TMGWMember ADD FBirthday DATETIME ALTER TABLE TMGWMember ADD FBirthdayType CHAR ALTER TABLE TMGWMember ADD FCompId BIGINT ALTER TABLE TMGWMember ADD FMemo VARCHAR(2222) ALTER TABLE TMGWMember ADD FCreateDate DATETIME -- UPDATE TMGWMember SET FDeleted = 1 WHERE 当前状态 != '正常' UPDATE TMGWMember SET FDeleted = 0 WHERE 当前状态 = '正常' --会员ID UPDATE TMGWMember SET FMemId = dbo.FNNewId() --会员主卡号 UPDATE TMGWMember SET FMemNo = 表面号 --姓名 UPDATE TMGWMember SET FName = 会员姓名 --手机 UPDATE TMGWMember SET FMobilePhone = 联系电话 --开户时间 UPDATE TMGWMember SET FCreateDate = 开户时间 --状态 UPDATE TMGWMember SET FState = 1 WHERE 当前状态='正常' --备注 UPDATE TMGWMember SET FMemo = 备注信息 --公司 UPDATE A SET A.FCompId = B.FCompId FROM TMGWMember AS A,TMGWCompany AS B WHERE A.店面 = B.FCompName --生日 UPDATE TMGWMember SET FBirthdayType = 'G' WHERE 会员生日 LIKE '%公历%' UPDATE TMGWMember SET FBirthdayType = 'L' WHERE 会员生日 LIKE '%农历%' UPDATE A SET FBirthday = -- SELECT CAST( '9999-' + REPLACE( REPLACE( REPLACE( REPLACE(会员生日,'月',''),'日',''),'[农历]',''),'[公历]','') AS DATETIME) FROM TMGWMember AS A WHERE 会员生日 LIKE '%公历%' AND 会员生日 != '1月-1日[公历]' SELECT 'EXEC PDeleteMemberSaleBill ' + CAST(FBillId AS VARCHAR(22)) FROM TMemberSaleBill Truncate table TMemberOldTransHist Truncate table TMemberCardOldAcctHist Truncate table TMemberArrear Truncate table TMemberArrearEmployee Truncate table TMemberRepay Truncate table TMemberCardAccount Truncate table TMemberCardAcctHist Truncate table TMemberCourse Truncate table TMemberTransHist Truncate table TMemberCourseHist Truncate table TMemberPointHist Truncate table TMemberPhoto