use jinan_juxing_meiping SELECT * INTO hyxx FROM hyxx SELECT * FROM xfxx SELECT * FROM hyxx WHERE klxmc = '普通顾客' SELECT * FROM jinan_juxing_meiping..hyxx GROUP BY klxmc UPDATE A SET A.FMobilePhone = B.lxdh FROM jinan_juxing_meiping..hyxx AS B,TMember AS A WHERE A.FMemId = B.FMemId 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 = dbo.FNNewId(),'' + hykmc ,hykmc,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 jinan_juxing_meiping..hyxx GROUP BY hykmc 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 NOT EXISTS(SELECT TOP 1 1 FROM TMemberCardTypeSub AS B WHERE B.FCompId = C.FId AND B.FCardTypeId = I.FId) --更新ID ALTER TABLE hyxx ADD FCourseId BIGINT ALTER TABLE hyxx ADD FItemId BIGINT ALTER TABLE hyxx ADD FMemId BIGINT ALTER TABLE hyxx ADD FMemNo VARCHAR(50) ALTER TABLE hyxx ADD FCardNo VARCHAR(50) ALTER TABLE hyxx ADD FCardTypeId BIGINT ALTER TABLE hyxx ADD FName VARCHAR(50) ALTER TABLE hyxx ADD FMobilePhone VARCHAR(50) ALTER TABLE hyxx ADD FTelephone VARCHAR(50) ALTER TABLE hyxx ADD FMemo VARCHAR(1000) ALTER TABLE hyxx ALTER COLUMN FMemo VARCHAR(8000) ALTER TABLE hyxx ADD FBirthday DATETIME ALTER TABLE hyxx ADD FCreateDate DATETIME ALTER TABLE hyxx ADD FIsCourse BIT ALTER TABLE hyxx ADD FCompId BIGINT ALTER TABLE hyxx ADD FBirhtday DATETIME ALTER TABLE hyxx ADD FPW VARCHAR(50) ALTER TABLE hyxx ADD FGender INT ALTER TABLE hyxx ADD FBriefCode VARCHAR(50) ALTER TABLE hyxx ADD FExpiredDate VARCHAR(100) ALTER TABLE hyxx ADD FBalance DECIMAL(18,6) ALTER TABLE hyxx ADD FRemainTimes DECIMAL(18,6) ALTER TABLE hyxx ADD FCardId BIGINT ALTER TABLE hyxx ADD FCardState INT ALTER TABLE hyxx ADD FCalcMode INT ALTER TABLE hyxx ADD FValueType INT UPDATE jinan_juxing_meiping..hyxx SET FMemId = dbo.FNNewId() WHERE FMemId IS NULL DELETE jinan_juxing_meiping..hyxx WHERE hybh = '00000' --卡号 UPDATE hyxx SET hykh = hykh UPDATE jinan_juxing_meiping..hyxx SET hybh = REPLACE(REPLACE(REPLACE(REPLACE( REPLACE( REPLACE(Replace(hybh,';',''),'?',''),'?',''),';',''),' ',''),':',''),'A','') ALTER TABLE TMember ALTER COLUMN FMobilePhone NVARCHAR(100) UPDATE jinan_juxing_meiping..hyxx SET FMobilePhone = isnull( replace(dbo.FNToDbc(FMobilePhone) ,' ',''),'') UPDATE jinan_juxing_meiping..hyxx SET FTelephone = '' UPDATE jinan_juxing_meiping..hyxx SET FTelephone = RIGHT(FMobilePhone,11) WHERE Len(FMobilePhone) > 20 UPDATE jinan_juxing_meiping..hyxx SET FMobilePhone = LEFT(FMobilePhone,11) WHERE Len(FMobilePhone) > 20 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, hybh AS FNo, hyxm AS FName, '' AS FBriefCode, 0 AS FTypeId, 1 AS FCompId, jrrq AS FCreateDate, case xb when '男' then 1 else 0 end AS FGender, 'G' AS FBirthdayType, FBirhtday AS FBirthday, FTelephone AS FTelephone, FMobilePhone 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 jinan_juxing_meiping..hyxx SELECT * FROM jinan_juxing_meiping..hyxx ORDER BY LEN(lxdh ) desc SELECT * FROM hyczk select * from hyxx WHERE klxmc = '计次卡' alter table hyxx ADD Times int default 0 not null UPDATE jinan_juxing_meiping..hyxx SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL UPDATE jinan_juxing_meiping..hyxx SET FCardNo = hybh UPDATE jinan_juxing_meiping..hyxx SET FBalance = knje UPDATE jinan_juxing_meiping..hyxx SET FMemo = bz UPDATE jinan_juxing_meiping..hyxx SET FValueType = 1 UPDATE jinan_juxing_meiping..hyxx SET FCompId = 1 UPDATE jinan_juxing_meiping..hyxx SET FCardState = 1 UPDATE jinan_juxing_meiping..hyxx SET FCreateDate = jrrq UPDATE jinan_juxing_meiping..hyxx SET FExpiredDate = DATEADD(YEAR,100,FCreateDate) UPDATE A SET A.FCardTypeId = B.FId FROM jinan_juxing_meiping..hyxx AS A,TMemberCardType AS B WHERE A.hykmc = B.FName INSERT INTO dbo.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, FValueType, FCompId AS FCompId, FMemId AS FMemId, FCardState AS FState, FCreateDate AS FCreateDate, FExpiredDate AS FExpiredDate, ISNULL(FRemainTimes,0) AS FTotalTimes, 0 AS FUsedTimes, 0 AS FSaleCompId, 0 AS FSaleBillId, FMemo AS FMemo FROM jinan_juxing_meiping..hyxx INSERT TMemberCardAccount(FId,FMemId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo) SELECT dbo.FNNewId(),FMemId,FCardId AS FCardId,3,FBalance,FBalance,0,jrrq,NULL,'' FROM jinan_juxing_meiping..hyxx INSERT TMemberCardAcctHist(FId,FMemId,FCardId,FAcctId,FTime,FCardTypeId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FArrear,FRecordTime,FMemo) select dbo.FNNewId(),C.FMemId,A.FCardId,A.FAcctId,getdate(),C.FTypeId,C.FCompId,'DR','Import',0,'',A.FBalance,0,A.FBalance,0,getdate(),'' from TMemberCardAccount AS A,TMemberCard AS C,jinan_juxing_meiping..hyxx AS D where C.FCardId = A.FCardId AND C.FCardId = D.FCardId INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo) SELECT dbo.FNNewId(),A.FMemId,rq,A.FCardId,A.FCompId,'DR','Import',xfid,'',cast(xfje as decimal(18,6)),1,cast(xfje as decimal(18,6)),'','','' FROM jinan_juxing_meiping..hyxf,TMemberCard AS A WHERE A.FCardNo = hybh select * from xfxx2 update xfxx2 set hykh = 'A' + hykh Truncate table TMemberOldTransHist select * from hyxf SELECT * FROM TMemberOld select dateadd(yy,100,getdate()) UPDATE TMemberCard SET FExpiredDate = dateadd(yy,100,FCreateDate) insert gcm12 (gcn00c,gcn01c,gcn02c,gcn09f,gcn10i,gcn12d,gcn13d,gcn15c,gcn17c,gcn22i,gcn24i,gcn04c,gcn06i,gcn03c,gcn16f) select '003',hykh,'0',knje,'0',jrrq,'22000101',hykh,'003','1','1',yddh,xb,hyxm,hyjf from gcm12_01 UPDATE TMemberCard SET FCompId = (SELECT FId FROM TCompany WHERE FNo= '003') UPDATE TMember SET FCompId = (SELECT FId FROM TCompany WHERE FNo= '003') UPDATE TMemberCardAcctHist SET FCompId = (SELECT FId FROM TCompany WHERE FNo= '003') SELECT * FROM TMemberSaleDetailPayment SELECT FId,FNo INTO #Member FROM TMember WHERE FNo LIKE 'A%' AND FCompId = 4734511574699135191 SELECT * FROM #Member UPDATE #Member SET FNo = REPLACE(REPLACE(REPLACE(REPLACE( REPLACE( REPLACE(Replace(FNo,';',''),'?',''),'?',''),';',''),' ',''),':',''),'','') UPDATE #Member SET FNo = REPLACE(FNo,'A','') WHERE FNo LIKE 'A%' UPDATE #Member SET FNo = 'A' + FNo WHERE FNo IN (SELECT FNo FROM TMember WHERE FCompId != 4734511574699135191) SELECT * FROM #Member WHERE FNo like 'A%' UPDATE B SET B.FNo = 'A' + B.FNo FROM #Member AS B, ( SELECT FNo, COUNT(1) as cnt,max(FId) as FId FROM #Member GROUP BY FNo ) AS A WHERE cnt > 1 AND B.FId = A.FId UPDATE A SET A.FNo = B.FNo FROM TMember AS A,#Member AS B WHERE A.FId = B.FId SELECT * FROM TMember WHERE FNo like 'A%' UPDATE A SET A.FNo = B.FNo, A.FFaceNo = B.FNo FROM TMemberCard AS A,TMember AS B WHERE A.FId = B.FId AND B.FCompId = 4734511574699135191 SELECT * FROM TMemberCard WHERE FNo like '%801127%'