use TaiYuan_YiYi SELECT * FROM Base_card SELECT * FROM TConsumeBill UPDATE TMemberCardType SET FAcctId2= 10 SELECT * FROM TPayAccount SELECT * FROM TItem SELECT * FROM BASE_KH SELECT * FROM BASE_KH_JC SELECT * FROM TItem --卡类别 ALTER TABLE Base_card ADD FID BIGINT UPDATE Base_card SET FId = 10000 + ID 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,'001' + BM,NAME as name,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 Base_card ALTER TABLE BASE_KH ADD mem_id BIGINT ALTER TABLE BASE_KH ADD card_id BIGINT ALTER TABLE BASE_KH ADD card_type_name VARCHAR(100) ALTER TABLE BASE_KH ADD mem_no VARCHAR(50) ALTER TABLE BASE_KH ADD card_No VARCHAR(50) ALTER TABLE BASE_KH ADD gender INT ALTER TABLE BASE_KH ADD mobile VARCHAR(50) ALTER TABLE BASE_KH ADD birthday_type VARCHAR(50) ALTER TABLE BASE_KH ADD birthday DATETIME ALTER TABLE BASE_KH ADD comp_id BIGINT ALTER TABLE BASE_KH ADD card_type_id BIGINT ALTER TABLE BASE_KH ADD memo VARCHAR(MAX) ALTER TABLE BASE_KH ADD balance DECIMAL(18,6) ALTER TABLE BASE_KH ADD balance2 DECIMAL(18,6) ALTER TABLE BASE_KH ADD point DECIMAL(18,6) ALTER TABLE BASE_KH ADD create_date datetime ALTER TABLE BASE_KH ADD expire_date datetime UPDATE BASE_KH SET card_id = dbo.FNNewId() WHERE card_id IS NULL UPDATE BASE_KH SET mem_id = dbo.FNNewId() WHERE mem_id IS NULL SELECT * FROM BASE_KH WHERE CARDNO = '582' --UPDATE imp_member SET FName = TEL UPDATE BASE_KH SET mobile = TEL UPDATE BASE_KH SET mem_no = CARDNO UPDATE BASE_KH SET card_no = CARDNO UPDATE BASE_KH SET gender = CASE WHEN sex = 1001 THEN 1 ELSE 0 END UPDATE BASE_KH SET memo = ISNULL(SM,'') UPDATE BASE_KH SET Point = KJF UPDATE BASE_KH SET birthday_type = 'G' UPDATE BASE_KH SET Balance = KYE UPDATE BASE_KH SET Create_date = kkdate UPDATE BASE_KH SET expire_date = dateadd(year,100,create_date) UPDATE BASE_KH SET comp_id = dbo.FNCompId('001') UPDATE A SET A.card_type_id = B.FId FROM BASE_KH AS A,BASE_CARD AS B WHERE A.HYCARD = B.BM 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, '' AS FMemo, '' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5 from BASE_KH INSERT INTO TMemberCard( FCardId, FCardNo, FTypeId, FValueType, FCompId, FMemId, FState, FCreateDate, FExpiredDate, FTotalTimes, FUsedTimes, FSaleCompId, FSaleBillId, FMemo) SELECT card_id AS FId, mem_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, 1 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 BASE_KH INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo) SELECT mem_id,dbo.FNNewId(),card_id AS card_id,3,balance,balance,0,create_date,NULL AS FExpiredDate,'' FROM BASE_KH 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 BASE_KH AS A SELECT * FROM BASE_FW ALTER TABLE BASE_FW ADD item_id BIGINT ALTER TABLE BASE_FW ADD course_id BIGINT UPDATE BASE_FW SET item_id = dbo.FNNewId() UPDATE BASE_FW SET course_id = dbo.FNNewId() 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 item_id,'001' + bm,name,name,name,0,dbo.FNGetFirstPinYin(name),'',1,1,1,'','','',1,FJG,FJG,0,0,0,0,0,1 FROM BASE_FW INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode) SELECT course_id AS FId, '001'+I.bm + '', I.name AS FName, '' AS FBriefCode, I.item_id AS FItemId, 0 AS FPackId, 1 AS FSequence, (SELECT TOP 1 FId FROM TBasicType WHERE FKey = 'CourseType') 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, 0 AS FPrice, 0 AS FAmount, 1 AS FCalcMode FROM BASE_FW AS I ALTER TABLE BASE_KH_JC ADD mem_id BIGINT ALTER TABLE BASE_KH_JC ADD card_id BIGINT ALTER TABLE BASE_KH_JC ADD course_id BIGINT ALTER TABLE BASE_KH_JC ADD remain_Times DECIMAL(18,6) ALTER TABLE BASE_KH_JC ADD Used_Pur_Times DECIMAL(18,6) ALTER TABLE BASE_KH_JC ADD Pur_Amount DECIMAL(18,6) ALTER TABLE BASE_KH_JC ADD Comp_Id BIGINT ALTER TABLE BASE_KH_JC ADD Item_Id BIGINT ALTER TABLE BASE_KH_JC ADD Pur_Times DECIMAL(18,6) ALTER TABLE BASE_KH_JC ADD Adjust_Price DECIMAL(18,6) ALTER TABLE BASE_KH_JC ADD create_date datetime ALTER TABLE BASE_KH_JC ADD expire_date datetime UPDATE BASE_KH_JC SET card_id = dbo.FNNewId() UPDATE A SET A.item_id = B.item_id, A.Course_Id = B.Course_Id FROM BASE_KH_JC AS A,BASE_FW AS B WHERE A.JCXM = B.BM SELECT * FROM BASE_KH_JC WHERE BM = 'k582' UPDATE A SET A.mem_id = B.mem_id, a.create_date = b.create_date FROM BASE_KH_JC AS A,BASE_KH AS B WHERE A.BM = B.bm UPDATE BASE_KH_JC SET pur_Times = ISNULL(yc,0) ,remain_Times = ISNULL(YC,0) , used_pur_times = ISNULL(yc,0)-ISNULL(YC,0), adjust_price = isnull(jg,0) UPDATE BASE_KH_JC SET comp_id = dbo.FNCompId('001') DELETE TMemberCourse INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FPurAmount,FFreeTimes,FUsedPurTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice) SELECT card_id,mem_id,course_id,0,item_id,comp_id,Pur_Times,ISNULL(Pur_Amount,0),0,used_pur_times,0,Create_Date,Expire_Date,'DR.Import',0,0,0,'从老系统导入',1,ISNULL(Adjust_Price,0) FROM BASE_KH_JC WHERE course_id IS NOT NULL INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes, FCompId, FBillType,FBizType,FBillId,FBillNo,FBillDetailId) SELECT dbo.FNNewId(),Mem_Id,card_Id,0,Course_Id,FTime = getdate(),Pur_Times,Pur_Times - Remain_Times,0,0, comp_id, 'DR','Import',0,'',0 FROM BASE_KH_JC WHERE course_id IS NOT NULL INSERT TItemSub(FId,FCompId,FItemId,FPrice,FVipPrice,FTime,FDctId,FPointMode,FPointValue,FDeptId,FAllowBooking,FEnabled) SELECT dbo.FNNewId(),C.FId,I.FId,I.FPrice,I.FVipPrice,I.FTime,I.FDctId,I.FPointMode,I.FPointValue,I.FDeptId,I.FAllowBooking,I.FEnabled FROM TItem AS I,TCompany AS C WHERE I.FId != 0 AND C.FId != 0 --AND C.FNo = '009' AND NOT EXISTS(SELECT TOP 1 1 FROM TItemSub AS B WHERE B.FCompId = C.FId AND B.FItemId = I.FId) 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 -- AND C.FNo = '009' AND NOT EXISTS(SELECT TOP 1 1 FROM TMemberCardTypeSub AS B WHERE B.FCompId = C.FId AND B.FCardTypeId = I.FId) SELECT * FROM BASE_KH WHERE CARDNO = '5200030' SELECT * FROM BASE_KH_JC WHERE BM = 'K582'