ALTER TABLE kxx ADD FCourseId BIGINT ALTER TABLE kxx ADD FItemId BIGINT ALTER TABLE kxx ADD FMemId BIGINT ALTER TABLE kxx ADD FMemNo VARCHAR(50) ALTER TABLE kxx ADD FCardTypeId BIGINT ALTER TABLE kxx ADD FName VARCHAR(50) ALTER TABLE kxx ADD FMobilePhone VARCHAR(50) ALTER TABLE kxx ADD FTelephone VARCHAR(50) ALTER TABLE kxx ADD FMemo VARCHAR(1000) ALTER TABLE kxx ALTER COLUMN FMemo VARCHAR(8000) ALTER TABLE kxx ADD FBirthday DATETIME ALTER TABLE kxx ADD FCreateDate DATETIME ALTER TABLE kxx ADD FIsCourse BIT ALTER TABLE kxx ADD FCompId BIGINT ALTER TABLE kxx ADD FBirhtday DATETIME ALTER TABLE kxx ADD FPW VARCHAR(50) ALTER TABLE kxx ADD FGender INT ALTER TABLE kxx ADD FBriefCode VARCHAR(50) ALTER TABLE kxx ADD FExpiredDate VARCHAR(100) ALTER TABLE kxx ADD FBalance DECIMAL(18,6) ALTER TABLE kxx ADD FRemainTimes DECIMAL(18,6) ALTER TABLE kxx ADD FCardId BIGINT ALTER TABLE kxx ADD FCardState INT ALTER TABLE kxx ADD FCalcMode INT ALTER TABLE kxx ADD FValueType INT ALTER TABLE kxx ADD FDeleted INT 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(),编号,类型,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 klx WHERE 优惠类型 = '快速扣费' 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 = dbo.FNCompId('001') AND NOT EXISTS(SELECT TOP 1 1 FROM TMemberCardTypeSub AS B WHERE B.FCompId = C.FId AND B.FCardTypeId = I.FId) --疗程类别 UPDATE A SET A.FCourseId = B.FId, A.FItemId = B.FItemId FROM kxx AS A,ZhaoYuan_JingDian.dbo.TItem AS I,ZhaoYuan_JingDian.dbo.TCourse AS B WHERE A.klxmc = I.FName AND B.FItemId = I.FId AND A.FIsCourse = 1 --储值卡类别 UPDATE A SET A.FCardTypeId = C.FId, A.FValueType = C.FValueType FROM kxx AS A,TMemberCardType AS C WHERE A.发卡类型 = c.FName SELECT * FROM kxx UPDATE kxx SET FMemId = dbo.FNNewId(), FCardId = dbo.FNNewId(), FMemNo = kh, FName = replace(xm,' ',''), FMobilePhone = replace(dbo.FNToDBC(isnull(tel,'')) ,' ',''), FTelephone = replace(dbo.FNToDBC(isnull(电话1,'')) ,' ',''), FBriefCode = isnull(xm,''), FCompId = dbo.FNCompId('001'), FCreateDate = 发卡日期, FExpiredDate = sxrq, FGender = case a.xb when '男' then 1 else 0 end , FBirthday = NULL, FPW = mm, FCardState = 1, FBalance = je, FMemo = isnull(a.beizhu,'') FROM kxx as a UPDATE kxx SET FDeleted = 0 UPDATE kxx SET FDeleted = 1 WHERE zt = '回收' --密码,有效期,卡ID UPDATE A SET A.FExpiredDate = '' FROM kxx AS A UPDATE A SET A.FExpiredDate = REPLACE(ISNULL(a.dzyj,'9000-12-31'),' ','') FROM kxx AS A SELECT * FROM kxx UPDATE A SET A.FRemainTimes = b.dqje FROM kxx AS A,hyczk AS B WHERE A.hykh = b.hykh AND A.FValueType = 3 --插入会员 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, FMemNo, FName, FBriefCode, 0 AS FTypeId, FCompId, FCreateDate, FGender, 'G' AS FBirthdayType, FBirthday, FTelephone AS FTelephone, FMobilePhone, '' AS FQQ, '' AS FWeChat, '' AS FIdCard, '' AS FEmail, '' AS FAddress, 0 AS FProId, ISNULL(FPW,'') AS FCPW, ISNULL(FPW,'') AS FQPW, 0 AS FChargeEmpId, 0 AS FPoint, 1 AS FRecvConsSMS, 1 AS FRecvBulkSMS, '', '' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5 from kxx WHERE FDeleted = 0 -- INSERT INTO dbo.TMemberCard( FCardId, FCardNo, FCardFaceNo, FTypeId, FValueType, FCompId, FMemId, FState, FCreateDate, FExpiredDate, FTotalTimes, FUsedTimes, FSaleCompId, FSaleBillId, FMemo) SELECT FCardId AS FId, FMemNo AS FNo, FMemNo 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 kxx WHERE FDeleted = 0 INSERT TMemberCardAccount(FId,FMemId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo) SELECT dbo.FNNewId(),FMemId,FCardId AS FCardId,3,ISNULL(FBalance,0),ISNULL(FBalance,0),0,FCreateDate,NULL,'' FROM kxx WHERE FDeleted = 0 INSERT dbo.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,'',ISNULL(A.FBalance,0),0,ISNULL(A.FBalance,0),0,getdate(),'' from dbo.TMemberCardAccount AS A,dbo.TMemberCard AS C,kxx AS D where C.FCardId = A.FCardId AND C.FCardId = D.FCardId AND C.FDeleted = 0 --------------------- end ----------------- INSERT ZhaoYuan_JingDian.dbo.TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FPurAmount,FFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice) SELECT FCardId,FMemId,FCourseId,0,FItemId,FCompId,FRemainTimes,FRemainTimes,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'',FCalcMode,0 FROM kxx WHERE FIsCourse = 1 AND FDeleted = 0 INSERT INTO ZhaoYuan_JingDian.dbo.TMemberCourseHist(FId,FMemId,FMemCourseId,FPackId,FCourseId,FTime,FPurTimes,FFreeTimes,FUsePurTimes,FUseFreeTimes, FPurAmount,FFreeAmount,FUsePurAmount,FUseFreeAmount,FCompId, FBillType,FBizType,FTransId,FTransNo,FTransDetailId) SELECT dbo.FNNewId(),FMemId,FCardId,0,FCourseId,FTime = getdate(),0,0,0,0, 0,0,0,0,1, 'DR','Import',0,'',0 FROM kxx WHERE FIsCourse = 1 --交易历史 TRUNCATE TABLE TMemberOldTransHist INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo) SELECT b.id,A.FMemId,xfrq,A.FCardId,A.FCompId,'DR','Import','',bz,cast(dzhje as decimal(18,6)),1,cast(dzhje as decimal(18,6)),'','','' FROM xfxx3 AS B,TMemberCard AS A ,kxx3 AS C WHERE replace(C.hykh,'C','') = B.hykh AND C.FCardId = A.FCardId SELECT * FROM xfxx1a SELECT klxmc FROM kxx group by klxmc ORDER BY klxmc ALTER TABLE kxx ADD FCourseId select * from kxx WHERE klxmc = '头皮理疗卡' SELECT * INTO kxx FROM master..kxx SELECT * INTO xfxx FROM master..xfxx SELECT * FROM kxx WHERE klxmc = '普通顾客' SELECT * FROM kxx WHERE bzxx is not null SELECT * FROM kxx WHERE hykh = '702058' SELECT * FROM hyczk WHERE hykh = '702058' SELECT * FROM hyczk WHERE kzt != '可用' SELECT klxmc FROM kxx GROUP BY klxmc SELECT qtxx,lxdz FROM kxx GROUP BY qtxx SELECT SELECT yddh ,sum(1) from kxx GROUP BY yddh SELECT * FROM TCompany WHERE FId = 4734511574699135191 update kxx SET id = '2000' + cast(id as varchar(20)) SELECT * FROM kxx UPDATE kxx SET hykh = 'A' + hykh SET hykh = REPLACE(REPLACE(REPLACE(REPLACE( REPLACE( REPLACE(Replace(hykh,';',''),'?',''),'?',''),';',''),' ',''),':',''),'A','') drop table kxx SELECT a.id AS FId, a.hykh AS FNo, a.hyxm AS FName, isnull(a.xmjm,'') AS FBriefCode, 0 AS FTypeId, 1 AS FCompId, a.jrrq AS FCreateDate, case a.xb when '男' then 1 else 0 end AS FGender, 'G' AS FBirthdayType, a.csrq AS FBirthday, '' AS FTelephone, isnull( replace(dbo.todbc(a.yddh) ,' ',''),'') 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(a.lxdz,'') + char(10) + isnull(a.qtxx,'') + char(10) AS FMemo, '' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5 from kxx as a SELECT hykh,sum(1) FROM kxx group by hykh order by sum(1) desc SELECT * FROM kxx WHERE hykh = '801218' UPDATE TMemberOldTransHist SET FCompId = 1 SELECT yddh from kxx order by len(yddh) desc ALTER TABLE ALTER TABLE www.ZhaoYuan_JingDian.dbo.TMember ALTER COLUMN FMoiblePhone VARCHAR(50) INSERT INTO www.ZhaoYuan_JingDian.dbo.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 id AS FId, hykh AS FNo, hyxm AS FName, isnull(xmjm,'') AS FBriefCode, 0 AS FTypeId, 1 AS FCompId, jrrq AS FCreateDate, case xb when '男' then 1 else 0 end AS FGender, 'G' AS FBirthdayType, csrq AS FBirthday, '' AS FTelephone, isnull( replace(dbo.todbc(yddh) ,' ',''),'') 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(lxdz,'') AS FMemo, '' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5 from kxx SELECT klxmc FROM kxx group by klxmc ORDER BY klxmc ALTER TABLE kxx ADD FCourseId select * from kxx WHERE klxmc = '包次黑油' alter table kxx ADD Times int default 0 not null UPDATE kxx SET Times = knje,knje = knje * 10 where klxmc = '计次卡' SEL INSERT INTO TMemberCard( FCardId, FCardNo, FFaceNo, FTypeId, FValueType, FCompId, FMemId, FState, FCreateDate, FExpiredDate, FTotalTimes, FUsedTimes, FSaleCompId, FSaleBillId, FMemo) SELECT id AS FId, hykh AS FNo, hykh AS FFaceNo, (SELECT FId FROM TMemberCardType WHERE FName = klxmc) AS FTypeId, (SELECT FValueType FROM TMemberCardType WHERE FName = klxmc) AS FValueType, 1 AS FCompId, id AS FMemId, 1 AS FState, jrrq AS FCreateDate, dateadd(yy,100,jrrq) AS FExpiredDate, Times AS FTotalTimes, 0 AS FUsedTimes, 0 AS FSaleCompId, 0 AS FSaleBillId, ISNULL(qtxx,'') AS FMemo FROM kxx INSERT TMemberCardAccount(FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo) SELECT dbo.FNNewId(),id AS FCardId,3,FBalance,FBalance,0,jrrq,NULL,'' FROM kxx 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,kxx AS D where C.FId = A.FCardId AND C.FId = D.id INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo) SELECT id,A.FMemId,xfrq,A.FCardId,A.FCompId,'DR','Import','','',cast(dzhje as decimal(18,6)),1,cast(dzhje as decimal(18,6)),'','',bz FROM xfxx1a,TMemberCard AS A WHERE A.FCardNo = hykh select * from xfxx2 update xfxx2 set hykh = 'A' + hykh Truncate table TMemberOldTransHist select * from xfxx 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') DELETE TMember WHERE FMemId > 0 UPDATE TMemberCardAcctHist SET FCompId = (SELECT FId FROM TCompany WHERE FNo= '003') SELECT * FROM TMemberSaleDetailPayment 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%'