SELECT * FROM TMemberCardType SELECT * FROM TMemberImport SELECT * FROM TMemberImportEx DELETE TMemberCardType WHERE FId > 0 INSERT INTO TMemberCardType(FId,FNo,FName,FValueType,FMaterial,FPrice,FCardFeeAmt,FAcctId,FDeposit,FAcctId2,FDeposit2, FAcctId3,FDeposit3,FTimes,FAlertBalance,FMinRecharge,FPaySmsFee,FTimeCard,FValidityPeriod,FValidityPeriodUnit,FExpiredDate, FDefaultMemo,FCreateTime,FAllowSale,FAllowRecharge,FAllowCross,FEnabled,FOrder,FDeptId) SELECT dbo.FNNewId() AS FId,卡名称 AS FNo,卡名称 AS FName,1 AS ValueType,1 AS FMaterial,0 AS FPrice,0 AS FCardFeeAmt,0 AS FAcctId,0 AS FDeposit,0 AS FAcctId2,0 AS FDeposit2,0 AS FAcctId3,0 AS FDeposit3,0 AS FTimes,0 AS FAlertBalance,0 AS FMinRecharge,0 AS FPaySmsFee,0 AS FTimeCard,0 AS FValidityPeriod,0 AS FValidityPeriodUnit,'' AS FExpiredDate,'' AS FDefaultMemo,'' AS FCreateTime,0 AS FAllowSale,0 AS FAllowRecharge,0 AS FAllowCross,1 AS FEnabled,0 AS FOrder,0 AS FDeptId FROM TMemberImport GROUP BY 卡名称 SELECT *INTO TMemberImport_Card FROM TMemberImport DELETE TMemberImport INSERT INTO TMemberImport(FId,FMemId,FMemNo,FCardId,FCardNo,FName,FGender,FMobilePhone,FCreateDate,FExpiredDate,FCardTypeId,FAcctId,FBalance,FAcctId2,FBalance2) SELECT dbo.FNNewId(),dbo.FNNewId(),FCardNo,dbo.FNNewId(),FCardNo,FName, 0 ,ISNULL(FMobilePhone,''),FCreateDate, Dateadd(yy,100,FCreateDate), 0,0,0,0,0 FROM TMemberCourseImportEx WHERE FCardNo NOT IN(select FNo FROM TMember) GROUP BY FCardNo,FName,FMobilePhone,FCreateDate SELECT * FROM TUser SELECT * FROM TMemberCourseImportEx WHERE FCourseNo NOT IN (SELECT FNo FROM TCourse) order by FCardNo ALTER TABLE TMemberCourseImportEx ADD FMemId BIGINT NOT NULL DEFAULT 0 ALTER TABLE TMemberCourseImportEx ADD FCourseId BIGINT NOT NULL DEFAULT 0 ALTER TABLE TMemberCourseImportEx ADD FId BIGINT NOT NULL DEFAULT 0 ALTER TABLE TMemberCourseImportEx ADD FItemId BIGINT NOT NULL DEFAULT 0 UPDATE TMemberCourseImportEx SET FId = dbo.FNNewId() update A SET A.FMemId = B.FId FROM TMemberCourseImportEx AS A,TMember AS B WHERE A.FCardNo = B.FNo update A SET A.FItemId = B.FItemId, A.FCourseId = B.FId FROM TMemberCourseImportEx AS A,TCourse AS B WHERE A.FCourseNo = B.FNo INSERT INTO TMemberImport(FId,FMemId,FMemNo,FCardId,FCardNo,FName,FGender,FMobilePhone,FCreateDate,FExpiredDate,FCardTypeId,FAcctId,FBalance,FAcctId2,FBalance2) SELECT dbo.FNNewId(),dbo.FNNewId(),FCardNo,dbo.FNNewId(),FCardNo,FName, 0 ,FMobilePhone,FCreateDate, Dateadd(yy,100,FCreateDate), (SELECT FId FROM TMemberCardType WHERE FNo=FCardTypeNo),3,FBalance,0,0 FROM TMemberImportEx WHERE FMobilePhone IS NULL SELECT * FROM TCompanY SELECT FCardNo,SUM(1) FROM TMemberCourseImportEx GROUP BY FCardNo SELECT * FROM TMemberCourseImportEx WHERE FRemainTimes IS NULL sp_rename 'TMemberCourseImportEx$','TMemberCourseImportEx' INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FPurAmount,FFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice) SELECT FId,FMemId,FCourseId,0,FItemId,1,ISNULL(FRemainTimes,0),CASE WHEN ISNULL(FRemainTimes,0) = 0 THEN 0 ELSE FRemainAmount END,0,0,getdate(),null,'DR.Import',0,0,0,'Excel导入',1,0 FROM TMemberCourseImportEx UPDATE TMemberCourseImportEx SET FId = dbo.FNNewId() INSERT INTO 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,FId,0,FCourseId,FTime = getdate(),ISNULL(FRemainTimes,0),FFreeTimes = 0,0,0, FPurAmount = CASE WHEN ISNULL(FRemainTimes,0) = 0 THEN 0 ELSE FRemainAmount END,0,0,0,1, 'DR','Import',0,'',0 FROM TMemberCourseImportEx DELETE TMemberCardAcctHist DELETE TMemberCardAccount DELETE TMemberCard DELETE TMember INSERT INTO TMember( FId, FNo, 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 FId, FMemNo AS FNo, FName AS FName, FBriefCode AS FBriefCode, 0 AS FTypeId, FCompId AS FCompId, FCreateDate AS FCreateDate, FGender AS FGender, FBirthdayType AS FBirthdayType, FBirthday AS FBirthday, FTelephone AS FTelephone, FMobilePhone AS FMobilePhone, '' AS FQQ, '' AS FWeChat, '' AS FIdCard, '' AS FEmail, '' AS FAddress, 0 AS FProId, FPW 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 TMemberImport INSERT INTO TMemberCard( FId, FNo, FFaceNo, 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, FCreateDate AS FCreateDate, FExpiredDate AS FExpiredDate, FRemainTimes AS FTotalTimes, 0 AS FUsedTimes, FCompId AS FSaleCompId, 0 AS FSaleBillId, FMemo AS FMemo FROM TMemberImport INSERT TMemberCardAccount(FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo) SELECT dbo.FNNewId(),FCardId AS FCardId,3,FBalance,FBalance,0,FCreateDate,FExpiredDate,FMemo FROM TMemberImport 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,A.FAcctId,getdate(),A.FCardTypeId,A.FCompId,'DR','Import',0,'',A.FBalance,0,A.FBalance,0,getdate(),'从Excel中导入' from TMemberImport AS A INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo) SELECT dbo.FNNewId(),A.FId,xfrq,A.FId,A.FCompId,'DR','Import','','',cast(dzhje as decimal(18,6)),1,cast(dzhje as decimal(18,6)),'','','' FROM xfxx,TMemberCard AS A WHERE A.FNo = 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') 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%' SELECT * FROM TMemberCardType UPDATE TMemberCardType SET FValidityPeriod = 1,FAllowRecharge = 1 UPDATE UPDATE TMember SET FBriefCode = dbo.FNGetFirstPinYin(FName) UPDATE TMemberCard SET FExpiredDate = DATEADD(yy,1,FCreateDate)