use JiNing_MiGe SELECT * FROM imp_member_rchg_hist SELECT * FROM imp_member_course use jining_piaoliangbaobei CREATE TABLE TImpCardType ( FName VARCHAR(500), FNo VARCHAR(50), FId BIGINT ) INSERT TImpCardType(FId,FNo,FName) SELECT dbo.FNnewId(),LevelName,LevelName FROM imp_member GROUP BY levelName --储值卡类别 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, FNo,FName,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 SELECT * FROM imp_member ALTER TABLE imp_member ADD mem_Id BIGINT ALTER TABLE imp_member ADD mem_no VARCHAR(50) ALTER TABLE imp_member ADD name VARCHAR(50) ALTER TABLE imp_member ADD gender INT //ALTER TABLE imp_member ADD mobile VARCHAR(50) ALTER TABLE imp_member ADD birthday_type VARCHAR(50) ALTER TABLE imp_member ADD birthday DATETIME ALTER TABLE imp_member ADD comp_id BIGINT ALTER TABLE imp_member ADD create_date DATETIME ALTER TABLE imp_member ADD memo VARCHAR(MAX) ALTER TABLE imp_member ADD balance DECIMAL(18,6) ALTER TABLE imp_member ADD balance2 DECIMAL(18,6) ALTER TABLE imp_member ADD card_no VARCHAR(50) ALTER TABLE imp_member ADD card_type_id BIGINT ALTER TABLE imp_member ADD expire_date DATETIME ALTER TABLE imp_member ADD card_id BIGINT ALTER TABLE imp_member ADD card_state INT UPDATE imp_member SET mem_id = dbo.FNNewId() WHERE mem_id IS NULL UPDATE imp_member SET card_id = dbo.FNNewId() WHERE card_id IS NULL UPDATE imp_member SET card_no = CardId UPDATE imp_member SET mem_no = CardId UPDATE imp_member SET name = CardName UPDATE imp_member SET mobile = '' where mobile is null UPDATE imp_member SET gender = CASE WHEN Sex = '2' THEN '1' ELSE 0 END UPDATE imp_member SET Birthday_Type = CASE WHEN birthdayType != '1' THEN 'L' ELSE 'G' END UPDATE imp_member SET Birthday = birthdayyear + '-' + birthdayMonth + '-' + birthdayday WHERE birthdayyear != 0 UPDATE imp_member SET comp_id = 1 UPDATE imp_member SET create_date = LEFT(createTime,4) + '-' + substring(createTime,5,2) + '-' + substring(createTime,7,2) UPDATE imp_member SET expire_date = dateadd(year,100,create_date); UPDATE imp_member SET card_state = 1 where state = 0 UPDATE imp_member SET card_state = 4 where state != 0 UPDATE A SET A.card_type_id= B.FId FROM imp_member AS A,TMemberCardTYPE AS B WHERE A.LevelName = b.fname UPDATE imp_member SET balance = Money UPDATE imp_member SET memo = Remark 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 mem_id AS FMemId, mem_no AS FMemNo, name AS FName, dbo.FNGetFirstPinYin(name), 0 AS FTypeId, comp_id AS FCompId, create_date AS FCreateDate, gender AS FGender, Birthday_Type AS FBirthdayType, Birthday AS FBirthday, '' AS FTelephone, ISNULL(Mobile,'') 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, ISNULL('','') AS FMemo, '' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5 from imp_member INSERT INTO TMemberCard( FCardId, FCardNo, FTypeId, FValueType, FCompId, FMemId, FState, FCreateDate, FExpiredDate, FTotalTimes, FUsedTimes, FSaleCompId, FSaleBillId, FMemo) SELECT card_id AS FId, card_no AS FNo, card_type_id AS FTypeId, (SELECT FValueType FROM TMemberCardType WHERE FId = card_type_id) AS FValueType, comp_id AS FCompId, mem_Id AS FMemId, card_state AS FState, Create_Date AS FCreateDate, Expire_Date AS FExpiredDate, 0 AS FTotalTimes, 0 AS FUsedTimes, Comp_Id AS FSaleCompId, 0 AS FSaleBillId, memo AS FMemo FROM imp_member INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo) SELECT mem_Id,dbo.FNNewId(),card_id AS FCardId,3,balance,balance,0,create_date,NULL AS FExpiredDate,'' FROM imp_member INSERT TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo) select dbo.FNNewId(),A.mem_Id,A.card_id,3,getdate(),A.card_type_id,A.comp_id,'DR','Import',0,'',A.balance,0,A.balance,0,getdate(),'从老系统中导入' FROM imp_member AS A --交易历史 ALTER TABLE imp_member_trans_hist ADD mem_id BIGINT ALTER TABLE imp_member_trans_hist ADD comp_id BIGINT ALTER TABLE imp_member_trans_hist ADD bill_time DATETIME ALTER TABLE imp_member_rchg_hist ADD mem_id BIGINT ALTER TABLE imp_member_rchg_hist ADD comp_id BIGINT ALTER TABLE imp_member_rchg_hist ADD bill_time DATETIME SELECT * FROM imp_member_trans_hist UPDATE imp_member_trans_hist SET bill_time = LEFT(createTime,4) + '-' + substring(createTime,5,2) + '-' + substring(createTime,7,2) + ' ' +substring(createTime,9,2) + ':' + substring(createTime,11,2) + ':' + substring(createTime,13,2) FROM imp_member_trans_hist UPDATE A SET A.mem_Id = B.mem_Id, A.comp_id = B.comp_id FROM imp_member_trans_hist AS A,imp_member AS B WHERE A.MemId = B.Id UPDATE imp_member_rchg_hist SET bill_time = LEFT(createTime,4) + '-' + substring(createTime,5,2) + '-' + substring(createTime,7,2) + ' ' +substring(createTime,9,2) + ':' + substring(createTime,11,2) + ':' + substring(createTime,13,2) FROM imp_member_rchg_hist UPDATE A SET A.mem_Id = B.mem_Id, A.comp_id = B.comp_id FROM imp_member_rchg_hist AS A,imp_member AS B WHERE A.MemId = B.Id INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo) SELECT Id,A.mem_id,a.bill_time,0,A.comp_id,'DR','Import',BillCode,Remark,A.totalmoney,1,A.totalmoney,payments,'','' FROM imp_member_trans_hist AS A INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo) SELECT Id,A.mem_id,a.bill_time,0,A.comp_id,'DR','Import',BillCode,Remark,A.totalmoney,1,A.totalmoney,payments,'','' FROM imp_member_rchg_hist AS A