SELECT * FROM TImpMember order by create_date desc alter Function FNStrToId ( @str varchar(100) ) RETURNS bigint AS BEGIN select @str = substring(@str,21,21) select @str = replace(@str,'-','') select @str = replace(@str,'a','1') select @str = replace(@str,'b','2') select @str = replace(@str,'c','3') select @str = replace(@str,'d','4') select @str = replace(@str,'e','5') select @str = replace(@str,'f','6') return @str END GO select dbo.FNStrToId(id),id FROM TImpMember SELECT * FROM TImpCard SELECT * FROM tb_memberCardCategory sp_rename 'tb_member','TImpMember' sp_rename 'tb_memberCard','TImpCard' sp_rename 'tb_memberCardCategory','TImpCardType' SELECT * FROM tb_memberCardAttrMap 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 FMemo VARCHAR(1000) ALTER TABLE TImpMember ADD FCreateDate DATETIME ALTER TABLE TImpMember ADD FBirthday DATETIME ALTER TABLE TImpCard ADD FMemId BIGINT ALTER TABLE TImpCard ADD FCardId BIGINT ALTER TABLE TImpCard ADD FCardNo VARCHAR(50) ALTER TABLE TImpCard ADD FCardTypeId BIGINT ALTER TABLE TImpCard ADD FBalance DECIMAL(18,6) ALTER TABLE TImpCard ADD FExpiredDate DATETIME ALTER TABLE TImpCard ADD FCreateDate DATETIME ALTER TABLE TImpCard ADD FCourseId BIGINT ALTER TABLE TImpCard ADD FRemainTimes INT ALTER TABLE TImpCard ADD FPurTimes INT ALTER TABLE TImpCard ADD FPurAmount DECIMAL(18,6) ALTER TABLE TImpCard ADD FIsCourse BIT ALTER TABLE TImpCard ADD FAdjustPrice DECIMAL(18,6) ALTER TABLE TImpCard ADD FCompId BIGINT ALTER TABLE TImpCard ADD FMemo VARCHAR(1000) ALTER TABLE TImpCard ADD FArrear DECIMAL(18,6) ALTER TABLE TImpMember ADD FPoint DECIMAL(18,6) ALTER TABLE TImpCard ADD FBirthday DATETIME ALTER TABLE TImpCard ADD FBirthdayType CHAR ALTER TABLE TImpCard ADD FDeleted BIT NOT NULL DEFAULT 0 UPDATE TImpMember SET FMemId = dbo.FNStrToId(id) UPDATE TImpMember SET FMemNo = memberNo UPDATE TImpMember SET FName = name UPDATE TImpMember SET FMobile = phonemobile UPDATE TImpMember SET FGender = sex UPDATE TImpMember SET FCreateDate = DATEADD(DAY,left(joinDate,10) / 24 / 3600,'1970-01-01') UPDATE TImpMember SET FBirthday = DATEADD(DAY,left(birthday,10) / 24 / 3600,'1970-01-01') UPDATE TImpMember SET FMemo = description UPDATE TImpCard SET FCardId = dbo.FNStrToId(id) UPDATE TImpCard SET FCardTypeId = dbo.FNStrToId(memberCardCategoryId) UPDATE TImpCard SET FMemId = dbo.FNStrToId(memberId) UPDATE TImpCard SET FCardNo = cardNo UPDATE TImpCard SET FBalance = cast(currentMoney as float) UPDATE TImpCard SET FCreateDate = DATEADD(DAY,left(create_date,10) / 24 / 3600,'1970-01-01') UPDATE TImpCard SET FPurAmount = FBalance --次数 UPDATE A SET A.FIsCourse = B.FIsCourse FROM TImpCard AS A,TImpCardTYpe AS B WHERE A.FCardTypeid = B.FId SELECT * FROM tb_memberCardAttrMap UPDATE A SET A.FRemainTimes = B.Value FROM TImpCard AS A, tb_memberCardAttrMap AS B WHERE A.Id = b.memberCardId UPDATE TImpCard SET FAdjustPrice = FPurAmount / FRemainTimes WHERE FIsCourse = 1 AND FRemainTimes > 0 UPDATE TImpCard SET FAdjustPrice = 0 WHERE FIsCourse = 1 AND FRemainTimes = 0 SELECT * FROM tb_memberCardAttrMap WHERE memberCardId = '1841800012639179756-efe58200-3481-11e6-beea-393429f2698d' SELECT * FROM TImpCard WHERE FRemainTimes IS NULL AND FIsCourse = 1 UPDATE TImpMember SET FExpiredDate = '9999-12-31' UPDATE TImpMember SET FArrear = 欠款 UPDATE TImpMember SET FMemo = ISNULL(REM,'') + '' + ISNULL(ACCREM,'') UPDATE TImpMember SET FPoint = 目前积分 UPDATE TImpMember SET FCardNo =FMobile WHERE FCardNo IS NULL SELECT DATEADD(DAY,left(joinDate,10) / 24 / 3600,'1970-01-01') FROM TImpMember ----------------------------------------- ---项目 exec sp_rename 'tb_service','TImpItem' exec sp_rename 'tb_service_cate','TImpItemType' SELECT * FROM TImpItem --项目 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 dbo.FNStrToId(id),baseInfo_code,baseInfo_code,name,'', dbo.FNStrToId(serviceCategory_id),'','',0,1,1,'','','',1,prices_salesprice,0,0,0,0,0,0,0 FROM TImpItem --类别 INSERT TBasicType(FId,FKey,FNo,FName,FParentId,FDescription,FCustom,FOrder,FAllowEdit,FEnabled) SELECT dbo.FNStrToId(id),'ItemType',name,name,0,'','',0,-1,1 FROM TImpItemType --员工 exec sp_rename 'tb_employee','TImpEmployee' SELECT * FROM TImpEmployee INSERT INTO TEmployee(FId,FNo,FName,FNickname,FEnLname,FEnFname,FDeptId,FPosId,FTechTypeId, FBriefCode,FGender,FStature,FWeight,FNationPlace,FNation,FEducation, FMarital,FCustom3,FCustom1,FCustom2,FAddress, FTelephone,FMobilePhone,FQQ,FEmail,FIdCard,FBirthdayType,FBirthday, FCardNo,FCardPW,FPW,FBank,FBankCardNo,FSSNo,FHCNo,FLinkMan,FLinkManTel, FLinkManAddr,FIntrId,FAllowSign,FAllowBooking,FContractType,FState, FCreatorId,FCreateDate,FEntryDate,FExpiredDate,FLeaveDate,FDescription) SELECT dbo.FNStrToId(id),name,name,name,'','',0,0,0,'',1,.000000,.000000,'','',0,0,'','','','','','','','','','G',NULL,'','','', 0,'','','','','','',0,0,1,1,1,0,'1753-01-01','1753-01-01','9999-12-31','9999-12-31','' FROM TImpEmployee UPDATE TIMpCardType SET FId = dbo.FNStrToId(Id) --卡类别 INSERT TMemberCardType(FId,FNo,FName,FValueType,FMaterial,FPrice,FAcctId,FDeposit,FAcctId2,FDeposit2,FAcctId3,FDeposit3,FTimes,FAlertBalance,FMinRchgAmt,FValidityPeriod,FValidityPeriodUnit,FExpiredDate,FDefaultMemo,FEnabled,FOrder,FSalePointMode,FSalePointValue,FRchgPointMode,FRchgPointValue) SELECT dbo.FNStrToId(Id),name,name,1,2,baseInfo_minMoney,3,baseInfo_minMoney,0,0,0,0,0,0,0,0,0,'9999-12-31','',1,0,0,0,0,0 FROM TIMpCardType WHERE FIsCourse = 0 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 dbo.FNStrToId(id),'L' + name,'L' + name,name,'', 0,'','',0,1,1,'','','',1,0,0,0,0,0,0,0,0 FROM TIMpCardType WHERE FIsCourse = 1 INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode) SELECT dbo.FNStrToId(id),'L' + name,'L' + name,'',dbo.FNStrToId(id),0,0,0,0,0,0,0,0,getdate(),getdate(),'',0,0,0,0 FROM TIMpCardType WHERE FIsCourse = 1 --导会员 SELECT FMemId,FMemNo,FName,FMobile,FCreateDate,FMemo ,FGender,FBirthday ,SUM(1) FROM TImpMember GROUP BY FMemId,FMemNo,FName,FMobile,FCreateDate,FMemo ,FGender,FBirthday ORDER BY SUM(1) DESC SELECT * FROM TImpMember WHERE FMemNO IN( SELECT FMemNo FROM TImpMember GROUP BY FMemNo HAVING(SUM(1) > 1) ) ORDER BY FMemNo DELETE TImpMember WHERE FRowVersion = 0x00000000000152AE SELECT * FROM TImpMember WHERE FMemNO = '65300231' 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, 1 AS FCompId, ISNULL(FCreateDate ,'1900-01-01') 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( 0,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 GROUP BY FMemId,FMemNo,FName,FMobile,FCreateDate,FMemo ,FGender,FBirthday --导卡 INSERT INTO TMemberCard( FCardId, FCardNo, FCardFaceNo, FTypeId, FValueType, FCompId, FMemId, FState, FCreateDate, FExpiredDate, FTotalTimes, FUsedTimes, FSaleCompId, FSaleBillId, FMemo) SELECT FCardId AS FId, FCardNo AS FNo, FCardNo AS FFaceNo, FCardTypeId AS FTypeId, (SELECT FValueType FROM TMemberCardType WHERE FId = FCardTypeId) AS FValueType, 1 AS FCompId, FMemId AS FMemId, 1 AS FState, ISNULL(FCreateDate,1900) AS FCreateDate, ISNULL(FExpiredDate,'9999-01-01'), 0 AS FTotalTimes, 0 AS FUsedTimes, 1 AS FSaleCompId, 0 AS FSaleBillId, '' AS FMemo FROM TImpCard WHERE FIsCourse = 0 AND FDeleted = 0 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 TImpCard AS A WHERE FCardTypeId IS NOT NULL AND FIsCourse = 0 AND FDeleted = 0 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 TImpCard AS A WHERE FCardTypeId IS NOT NULL AND FIsCourse = 0 AND FDeleted = 0 UPDATE TImpCard SET FDeleted = 1 WHERE FMemId NOT IN(SELECT FMemId FROM TImpMember) SELECT * FROM TImpCard WHERE FCardNO IN( SELECT FCardNO FROM TImpCard GROUP BY FCardNO HAVING(SUM(1) > 1) ) ORDER BY FCardNO UPDATE TImpCard SET FDeleted = 1 WHERE FRowVersion = 0x0000000000014A12 UPDATE TImpCard SET FDeleted = 1 WHERE FRowVersion = 0x000000000001498D UPDATE TImpCard SET FDeleted = 1 WHERE FRowVersion = 0x0000000000014D48 UPDATE TImpCard SET FDeleted = 1 WHERE FRowVersion = 0x000000000001496E UPDATE TImpCard SET FDeleted = 1 WHERE FRowVersion = 0x00000000000149F4 UPDATE TImpCard SET FDeleted = 1 WHERE FRowVersion = 0x000000000001495E SELECT * FROM TImpCard UPDATE TCourse SET FCalcMode = 1 SELECT * FROM TImpCardType WHERE FIsCourse= 1 select dbo.FNStrToid('1841800012639179756-04e238d0-09c5-11e5-8b5f-fbb39c76c2af') SELECT * FROM TImpCard WHERE FCardTypeId = 291553800829115519 SELECT * FROM TIMpCardType WHERE Id NOT IN(SELECT memberCardCategoryId FROM TIMPcARD) ALTER TABLE TIMpCardType ADD FIsCourse BIT NOT NULL DEFAULT 0 ALTER TABLE TImpCardType ADD FId BIGINT ALTER TABLE TImpCardType ADD FName VARCHAR(50) UPDATE TIMpCardType SET FId = abs( CAST( CAST(right(id,36) AS BINARY(16)) AS BIGINT)) UPDATE TIMpCardType SET FName = name UPDATE TIMpCardType SET FIsCourse = 1 WHERE baseInfo_type = 'recordTimeCard' --导疗程 INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FPurAmount,FFreeTimes,FUsedPurTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice) SELECT FCardId,FMemId,FCardTypeId,0,FCardTypeId,1,ISNULL(FRemainTimes,0),ISNULL(FPurAmount,0),0,0,0,getdate(),'9999-12-31','DR.Import',0,0,0,'',1,ISNULL(FAdjustPrice,0) FROM TImpCard WHERE FIsCourse = 1 INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes, FCompId, FBillType,FBizType,FBillId,FBillNo,FBillDetailId) SELECT dbo.FNNewId(),FMemId,FCardId,0,FCardTypeId,FTime = getdate(),ISNULL(FRemainTimes,0),0,0,0, 1, 'DR','Import',0,'',0 FROM TImpCard WHERE FIsCourse = 1