use xianning_xinghaian use kunming_gejiuwenfeng drop table TImpMember drop table TImpMemberCard SELECT COUNT(1) FROM TImpMemberCard SELECT COUNT(1) FROM TImpMember SELECT * FROM TImpMember SELECT * FROM TImpMemberCard UPDATE TImpMember SET 消费次数 = 当前积分,当前积分 = 最后消费日,最后消费日= 卡账户信息 where 当前积分 like '%次%' SELECT * FROM TImpMember where 当前积分 like '%次%' SELECT MemId,SUM(1) FROM TImpMemberCard GROUP BY MemId HAVING(SUM(1)) > 1 DROP TABLE TImpCardType CREATE TABLE TImpCardType ( FId BIGINT, FNo VARCHAR(50), FName VARCHAR(50), FType VARCHAR(50), FValueType INT ) ALTER TABLE TImpMemberCard ADD FCardTypeName VARCHAR(100) ALTER TABLE TImpMember ADD FMemId BIGINT ALTER TABLE TImpMemberCard ADD FMemId BIGINT ALTER TABLE TImpMemberCard ADD FCardNo VARCHAR(50) 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 FCreateDate DATETIME ALTER TABLE TImpMemberCard ADD FCardTypeId BIGINT ALTER TABLE TImpMemberCard ADD FCourseId BIGINT ALTER TABLE TImpMemberCard ADD FBalance DECIMAL(18,6) ALTER TABLE TImpMemberCard ADD FBalance2 DECIMAL(18,6) ALTER TABLE TImpMemberCard ADD FRemainTimes INT ALTER TABLE TImpMemberCard ADD FPurTimes INT ALTER TABLE TImpMemberCard ADD FPurAmount DECIMAL(18,6) ALTER TABLE TImpMemberCard ADD FItemId BIGINT ALTER TABLE TImpMemberCard ADD FCreateDate DATETIME ALTER TABLE TImpMemberCard ADD FExpiredDate DATETIME ALTER TABLE TImpMember ADD FCompId BIGINT ALTER TABLE TImpMemberCard ADD FCompId BIGINT ALTER TABLE TImpMemberCard ADD FCardId BIGINT ALTER TABLE TImpMember ADD FMemo VARCHAR(1000) ALTER TABLE TImpMemberCard ADD FMemo VARCHAR(1000) ALTER TABLE TImpMember ADD FArrear DECIMAL(18,6) ALTER TABLE TImpMember ADD FPoint DECIMAL(18,6) ALTER TABLE TImpMember ADD FBirthday DATETIME ALTER TABLE TImpMember ADD FBirthdayType CHAR ALTER TABLE TImpMember ADD FCustom1 VARCHAR(100) ALTER TABLE TImpMember ADD FPointText VARCHAR(100) ALTER TABLE TImpMember ADD FDeleted Bit ALTER TABLE TImpMemberCard ADD FDeleted Bit ALTER TABLE TImpMemberCourseDetail ADD FCardTypeId BIGINT ALTER TABLE TImpMemberCourseDetail ADD FItemId BIGINT ALTER TABLE TImpMemberCourseDetail ADD FRemainTimes INT ALTER TABLE TImpMemberCourseDetail ADD FPurTimes INT ALTER TABLE TImpMemberCourseDetail ADD FUsedTimes INT ALTER TABLE TImpMemberCourseDetail ADD FPurAmount DECIMAL(18,6) ALTER TABLE TImpMemberCourseDetail ADD FAdjustPrice DECIMAL(18,6) ALTER TABLE TImpMemberCourseDetail ADD FCreateDate DATETIME ALTER TABLE TImpMemberCourseDetail ADD FExpiredDate DATETIME ALTER TABLE TImpMemberCourseDetail ADD FCompId BIGINT ALTER TABLE TImpMemberCourseDetail ADD FCardId BIGINT ALTER TABLE TImpMemberCourseDetail ADD FMemId BIGINT ALTER TABLE TImpMemberCourseDetail ADD FMemo VARCHAR(1000) ALTER TABLE TImpMemberCourseDetail ADD FDeleted BIT SELECT * FROM TImpMemberCard WHERE storeName LIKE '%白鹭%' OR storeName LIKE '%北门店%' SELECT storeId,storeName FROM TImpMemberCard GROUP BY storeId,storeName DELETE TImpMemberCard WHERE storeId = 3752 --初始化卡类别 UPDATE TImpMemberCard SET FCardTYpeName = levelName + '[' + projectDiscount + '折]' DELETE TImpCardType INSERT TImpCardType(FId,FNo,FName,FValueType) SELECT dbo.FNNewId(),FCardTYpeName,FCardTYpeName , 1 FROM TImpMemberCard WHERE FCardTYpeName IS NOT NULL AND FCardTYpeName NOT IN(SELECT FName FROM TImpCardType) GROUP BY FCardTYpeName UPDATE TImpMember SET FDeleted = 0 UPDATE TImpMemberCard SET FDeleted = 0 UPDATE TImpMemberCard SET FDeleted = 1 WHERE isDeleted = 1 UPDATE TImpMember SET FDeleted = 1 WHERE isDeleted = 1 SELECT * FROM TImpMemberCard WHERE FMemo IS NULL -- INSERT INTO TCompany(FId,FNo,FName,FAbbr,FAddress,FTelephone,FEmail,FWebSite,FWeChatNo,FWeChatQRCode,FIntroduction,FAdmin,FIsCenter,FParentId) SELECT storeId,storeId,storeName,storeName,'','','','','','','','',0,1 FROM TImpMemberCard GROUP BY storeId,storeName --门店 SELECT * FROM TCompany UPDATE TImpMemberCard SET FCompId = NULL UPDATE TImpMember SET FCompId = dbo.FNCompId('002') WHERE storeName LIKE '%文峰美容美发中山店%' UPDATE TImpMemberCard SET FCompId = dbo.FNCompId('002') WHERE storeName LIKE '%文峰美容美发中山店%' UPDATE TImpMember SET FCompId = dbo.FNCompId('001') WHERE storeName LIKE '%文峰美容美发精致店%' UPDATE TImpMemberCard SET FCompId = dbo.FNCompId('001') WHERE storeName LIKE '%文峰美容美发精致店%' UPDATE TImpMember SET FCompId = dbo.FNCompId('001') WHERE storeName LIKE '%优美造型美容%' UPDATE TImpMemberCard SET FCompId = dbo.FNCompId('001') WHERE storeName LIKE '%优美造型美容%' select * from TImpMemberCourseDetail WHERE recordId = 128622 select * from TImpMemberCourse WHERE recordId = 128622 ALTER TABLE TImpMemberCourseDetail ADD storeId BIGINT UPDATE A SET A.storeId = B.storeId FROM TImpMemberCourseDetail AS A,TImpMemberCourse AS B WHERE A.recordId = B.recordId UPDATE TImpMemberCourseDetail SET FCompId = dbo.FNCompId('002') WHERE storeId = '3024' UPDATE TImpMemberCourseDetail SET FCompId = dbo.FNCompId('001') WHERE storeId = '3023' UPDATE TImpMemberCourseDetail SET FCompId = dbo.FNCompId('001') WHERE storeId = '3027' UPDATE TImpMember SET FDeleted = 1 WHERE FCompId IS NULL UPDATE TImpMemberCard SET FDeleted = 1 WHERE FCompId IS NULL --会员ID UPDATE TImpMember SET FMemId = memberId UPDATE TImpMemberCard SET FMemId = memberId --积分 UPDATE TImpMember SET FPoint = balanceIntegral --开卡日期 UPDATE TImpMember SET FCreateDate = createTime UPDATE TImpMemberCard SET FCreateDate = createTime UPDATE TImpMemberCard SET endDate = REPLACE(endDate,'-02-29','-02-28') WHERE endDate LIKE '%02-29' UPDATE TImpMemberCard SET FExpiredDate = endDate WHERE endDate != '' AND endDate < '9' UPDATE TImpMemberCard SET FExpiredDate = DATEADD(YEAR,100,FCreateDate) WHERE FExpiredDate IS NULL SELECT * FROM TImpMemberCard WHERE FDeleted = 0 AND FCardNo = '' --处理卡号 UPDATE TImpMemberCard SET FCardNo = cardNo --空卡号 UPDATE A SET A.FCardNo = B.Phone FROM TImpMemberCard AS A,TImpMember AS B WHERE A.MemberId = B.memberId AND A.FDeleted = 0 AND B.FDeleted = 0 AND A.FCardNo = '' --处理重复卡号 DROP TABLE #Card SELECT FCardNo into #Card FROM TImpMemberCard WHERE FDeleted= 0 GROUP BY FCardNo HAVING(SUM(1)) > 1 SELECT * FROM TImpMemberCard WHERE FCardNo = '8882200992' ALTER TABLE TImpMemberCard ADD FSeq INT IDENTITY ALTER TABLE TImpMemberCard ADD FIndex INT SELECT * FROM #Card UPDATE A SET A.FIndex = 1+(SELECT COUNT(1) FROM TImpMemberCard AS B WHERE A.FCardNo = B.FCardNo AND (A.FCreateDate > B.FCreateDate OR (A.FCreateDate = B.FCreateDate AND (A.FSeq > B.FSeq) ))) FROM TImpMemberCard AS A SELECT * FROM TImpMemberCard WHERE FCardNo IN(SELECT FCardNO FROM #Card) AND FIndex > 0 order by FCardNo --删除完全一样的 UPDATE TImpMemberCard SET FCardNo = FCardNo + '.' + CAST(FIndex AS VARCHAR) WHERE FCardNo IN( SELECT FCardNo FROM #Card) AND FDeleted = 0 SELECT FCardNo,SUM(1) AS Cnt FROM TImpMemberCard WHERE FDeleted = 0 GROUP BY FCardNo ORDER BY SUM(1) DESC SELECT FMemNo,FMobile,SUM(1) AS Cnt FROM TImpMember GROUP BY FMemNo ,FMobile ORDER BY SUM(1) DESC SELECT FMemNo,SUM(1) AS Cnt FROM TImpMember WHERE FMemId IN(SELECT FMemId FROM TImpMemberCard) GROUP BY FMemNo ORDER BY SUM(1) DESC SELECT * FROM TImpMember WHERE FMemNo = '15103405980' SELECT * FROM TImpMemberCard WHERE FMemId = '45294303' SELECT * FROM TImpMemberCard UPDATE TImpMemberCard SET FCardId = subAccountId UPDATE TImpMemberCard SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL --会员编号 UPDATE A SET A.FMemNo = B.FCardNo FROM TImpMember AS A,TImpMemberCard AS B WHERE A.memberId = B.memberId AND A.FDeleted = 0 UPDATE TImpMember SET FMemNo = phone WHERE ISNULL(FMemNo,'') = '' UPDATE TImpMember SET FName = name UPDATE TImpMember SET FMobile = phone UPDATE TImpMember SET FGender = CASE WHEN sex = '男' THEN 1 ELSE '0' END UPDATE TImpMember SET FName = FMobile WHERE FName = '' UPDATE TImpMember SET FName = FMemNo WHERE FName = '' SELECT * FROM TImpMember WHERE FMemID = 2379418 SELECT * FROM TImpMemberCard WHERE remarks != '' UPDATE TImpMember SET FArrear = 0 UPDATE TImpMember SET FMemo = FMemo --门店 SELECT * FROM TImpMemberCard WHERE FCardTypeID IS NULL SELECT * FROM TImpCardType --卡类别 UPDATE A SET A.FCardTypeId = B.FId FROM TImpMemberCard AS A,TImpCardType AS B WHERE A.FCardTypeName= B.FName SELECT * FROM TImpMemberCard UPDATE TImpMember SET FBirthdayType = 'G' SELECT * FROM TImpMemberCard WHERE FMemo IS NULL --门店 UPDATE TImpMember SET FCompId = 4700258612397082011 SELECT * FROM TImpMemberCard --备注 update TImpMemberCard SET FMemo = REMARKS --余额 UPDATE TImpMemberCard SET FBalance = balanceAmount UPDATE TImpMemberCard SET FBalance2 = balanceGiftmoneyAmount SELECT * FROM TImpMemberCard WHERE FBalance2 != 0 AND FDeleted = 0 -- UPDATE TImpMember SET FMemno = 'JY' + FMemNO,FCardNo = 'JY' + FCardnO SELECT * FROM TImpMemberCard WHERE FCardTypeId IS NULL SELECT * FROM TImpMember WHERE FMemno = '10839' SELECT count(1) FROM TImpMemberCard WHERE remarks is null SELECT * FROM TImpMemberCourse delete TMemberCardType WHERE FId > 100 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 ,FNo,FName,FValueType,2,0,0,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 FROM TImpCardType WHERE FId NOT IN(SELECT FId FROM TMemberCardType) ORDER BY FNo SELECT * FROM TImpCardType UPDATE TMemberCardType SET FAllowRchg = 1 WHERE FId IN(SELECT FId FROM TImpCardType) UPDATE TMemberCardType SET FAllowSale = 1 WHERE FId IN(SELECT FId FROM TImpCardType) UPDATE TMemberCardType SET FEnabled = 1 WHERE FId IN(SELECT FId FROM TImpCardType) UPDATE TMemberCardType SET FValidityPeriod = 100 WHERE FId IN(SELECT FId FROM TImpCardType) UPDATE TMemberCardType SET FValidityPerioduNIT = 1 WHERE FId IN(SELECT FId FROM TImpCardType) 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 IN(SELECT FId FROM TImpCardType) --AND C.FId = dbo.FNCompId('002') 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.FValueType = 3 FROM TMemberCardType AS A,TImpCardType AS B WHERE A.FId = B.FId --疗程 drop table TImpItem CREATE TABLE TImpItem ( FItemId BIGINT, FCourseId BIGINT, FItemName VARCHAR(100), ) INSERT TImpItem(FItemId,FCourseId,FItemName) SELECT dbo.FNNewId(),dbo.FNNewId(),projectName FROM TImpMemberCourseDetail WHERE projectName NOT IN(SELECT FItemName FROM TImpItem) GROUP BY projectName 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,FDisplay) SELECT FItemId,'L' + FItemName,'',FItemName,FItemName,0,dbo.FNGetFirstPinYin(FItemName),'',1,1,1,'','','',1,0,0,0,0,1,0,0,1,1 FROM TImpItem WHERE FItemId NOT IN(SELECT FId FROM TItem) DELETE TCourse WHERE FItemId IN(SELECT FItemId FROM TImpiTEM) INSERT INTO TCourse(FId,FNo,FName,FBriefCode,FItemId,FPackId,FSequence,FTypeId,FTimes,FFreeTimes,FDurable,FValidityPeriodUnit,FValidityPeriod,FCreateDate,FExpiredDate,FDescription,FEnabled,FPrice,FAmount,FCalcMode) SELECT FCourseId, I.FItemName + 'L1', I.FItemName , dbo.FNGetFirstPinyin(FItemName) AS FBriefCode, I.FItemId AS FItemId, 0 AS FPackId, 1 AS FSequence, 0 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 TImpItem AS I WHERE FItemId NOT IN(SELECT FItemId FROM TCourse) SELECT projectName FROM TImpMemberCourseDetail GROUP BY projectName UPDATE A SET A.FDeleted = B.FDeleted FROM TImpMember AS B,TImpMemberCourseDetail AS A WHERE A.memberId = B.memberId SELECT * FROM TImpMemberCourseDetail UPDATE TImpMemberCourseDetail SET FCardId = dbo.FNNewId() WHERE FCardId IS NULL UPDATE TImpMemberCourseDetail SET FExpiredDate = NULL UPDATE TImpMemberCourseDetail SET FMemo = '' UPDATE A SET A.FItemId = B.FItemId, A.FCardTypeId = B.FCourseId FROM TImpMemberCourseDetail AS A,TImpItem AS B WHERE A.projectName = B.FItemName SELECT * FROM TImpMemberCourseDetail UPDATE TImpMemberCourseDetail SET FRemainTimes = remainingCount UPDATE TImpMemberCourseDetail SET FPurTimes = projectCount UPDATE TImpMemberCourseDetail SET FPurAmount = projectCount * cast(singlecomboprice as float) UPDATE TImpMemberCourseDetail SET FAdjustPrice = cast(singlecomboprice as float) UPDATE TImpMemberCourseDetail SET FUsedTimes = FPurTimes - FRemainTimes UPDATE TImpMemberCourseDetail SET FCreateDate = createTime UPDATE TImpMemberCourseDetail SET FMemId = memberId UPDATE TImpMemberCourseDetail SET FCardId = detailId SELECT * FROM TImpMemberCourseDetail WHERE FCardTYPEID IS NULL SELECT * FROM TImpMemberCourseDetail WHERE memberId NOT IN(SELECT memberId FROM TImpMember) SELECT * FROM TImpMember2 WHERE memberId NOT IN(SELECT memberId FROM TImpMember) INSERT TImpMember(memberId,name,sex,phone) SELECT memberId,name,sex,phone FROM TIMpMEMBER2 WHERE memberId NOT IN(SELECT memberId FROM TImpMember) SELECT * FROM TImpMember UPDATE TImpMemberCourseDetail SET FCompId = dbo.FNCompId('001') DROP TABLE TImpMemberCourseDetail 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, FCompId AS FCompId, ISNULL(FCreateDate ,'1900-01-01') AS FCreateDate, FGender AS FGender, FBirthdayType 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( FPoint,0) AS FPoint, 1 AS FRecvConsSMS, 1 AS FRecvBulkSMS, ISNULL('','') AS FMemo, '' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5 from TImpMember WHERE FDeleted = 0 SELECT * FROM TIMpMember WHERE FMemNO iN(SELECT FMemNO FROM TMember) SELECT * FROM TImpMember WHERE FMemId = 3347836 /* SELECT * FROM TImpMember WHERE FMemId IN( SELECT FMemId,FMemNo,FName,FMobile,FGender,FCompId ,FBirthdayType ,FBirthday,FCreateDate,FPoint INTO #Temp FROM TImpMember GROUP BY FMemId,FMemNo,FName,FMobile,FGender,FCompId ,FBirthdayType ,FBirthday,FCreateDate,FPoint ORDER BY SUM(1) DESC ) SELECT FMemId FROM #Temp GROUP BY FMemId HAVING(SUM(1)) > 1 SELECT * FROM TImpmEMBER WHERE FMemId = 25006217 UPDATE TImpMember SET FMemNo = '0000330' WHERE FMemId = 25463627 UPDATE TImpMember SET FMemNo = '0000055' WHERE FMemId = 25006217 */ 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, FCompId AS FCompId, FMemId AS FMemId, 1 AS FState, FCreateDate AS FCreateDate, FExpiredDate AS FExpiredDate, ISNULL(FRemainTimes,0) AS FTotalTimes, 0 AS FUsedTimes, FCompId AS FSaleCompId, 0 AS FSaleBillId, ISNULL(FMemo,'') AS FMemo FROM TImpMemberCard WHERE FDeleted = 0 SELECT * FROM TImpMember WHERE FCardId IS NULL WHERE CardNo IS NOT NULL INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo) SELECT FMemId,dbo.FNNewId(),FCardId AS FCardId,3,FBalance,FBalance,0,FCreateDate,NULL AS FExpiredDate,'' FROM TImpMemberCard AS A WHERE 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,A.FCompId,'DR','Import',0,'',A.FBalance,0,A.FBalance,0,getdate(),'从盛传中导入' FROM TImpMemberCard AS A WHERE FDeleted = 0 INSERT TMemberCardAccount(FMemId,FId,FCardId,FAcctId,FDeposit,FBalance,FArrear,FCreateDate,FExpiredDate,FMemo) SELECT FMemId,dbo.FNNewId(),FCardId AS FCardId,10,FBalance2,FBalance2,0,FCreateDate,NULL AS FExpiredDate,'' FROM TImpMemberCard AS A WHERE FBalance2 != 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,10,getdate(),A.FCardTypeId,A.FCompId,'DR','Import',0,'',A.FBalance2,0,A.FBalance2,0,getdate(),'从盛传中导入' FROM TImpMemberCard AS A WHERE FBalance2 != 0 AND FDeleted = 0 --疗程 INSERT TMemberCourse(FId,FMemId,FCourseId,FMemPackId,FItemId,FCompId,FPurTimes,FUsedPurTimes,FPurAmount,FFreeTimes,FFreeAmount,FPurchaseDate,FExpiredDate,FBizType,FTransId,FArrear,FDurable,FMemo,FCalcMode,FAdjustPrice) SELECT FCardId,FMemId,FCardTypeId,0,FItemId,FCompId,FPurTimes,FPurTimes-FRemainTimes,FPurAmount,0,0,FCreateDate,FExpiredDate,'DR.Import',0,0,0,'从智放中导入',1,FAdjustPrice FROM TImpMemberCourseDetail AS A WHERE FDeleted = 0 INSERT INTO TMemberCourseLog(FId,FMemId,FCardId,FPackId,FCourseId,FTime,FInPurTimes,FInFreeTimes,FOutPurTimes,FOutFreeTimes,FCompId,FBillType,FBizType,FBillId,FBillNo,FBillDetailId,FRecordTime) SELECT dbo.FNNewId(),FMemId,A.FCardId AS FCardId,0, ISNULL(FCardTypeId,0),getdate(),FPurTimes,0,FPurTimes-FRemainTimes,0,FCompId,'DR','Import',0,'',0,getdate() FROM TImpMemberCourseDetail AS A WHERE FDeleted = 0 SELECT * FROM TImpMember WHERE FBalance2!= 0 SELECT * FROM TImpMember AS A WHERE FBalance2 != 0 SELECT * FROM TImpTransHist ALTER TABLE TImpTransHist ADD FCompId BIGINT ALTER TABLE TImpTransHist ADD FTime DATETIME UPDATE TImpTransHIst SET FtIME = REPLACE(Time,'消费日期:','') UPDATE TImpTransHist SET FCompID = DBO.FNCompId('011') UPDATE SELECT * FROM TImpTransHist INSERT TMemberOldTransHist(FId,FCompId,FMemId,FTime,FCardId,FBIllType,FBizType,FTransNo,FCOntent,FPrice,FQuantity,FAmount,FPayment,Femployee,FMemo) SELECT dbo.FNNewId(),FCompId,MemId,FTime,CardId,'',BizType,BillNo, ISNULL(Content,''),0,1,0,Amount,Employee, Memo AS FMemo FROM TImpTransHist WHERE FMemId IS NOT NULL AND FMemId IN(SELECT FMemId FROM TImpMember3) SELECT * FROM TCompany SELECT * FROM TMemberCard WHERE FMemo != '' SELECT * FROM TImpMember where isnull(FMemo,'') != '' ALTER TABLE TImpMember ADD ShopId USE MAIN SELECT * FROM TClientInfo WHERE FClientName LIKE '%海岸%' SELECT * FROM TImpMemberTransHist SELECT * FROM TImpMember UPDATE A SET A.FCompId = B.FCompID FROM TMember AS A,TImpMember AS B WHERE A.FMemId = B.FMemId UPDATE A SET A.FCompId = B.FCompID FROM TMemberCard AS A,TImpMemberCard AS B WHERE A.FCardId = B.FCardId UPDATE A SET A.FCompId = B.FCompID FROM TMemberCourse AS A,TImpMember AS B WHERE A.FMemId = B.FMemId SELECT * FROM TImpMember WHERE FMemNo = '07150001607856' SELECT * FROM TImpMemberCard WHERE FCardNo = '07150001607856' SELECT * FROM TMember WHERE FMemNo = '07150001607856' SELECT * FROM TImpMemberCard WHERE subAccountId = 3348635 UPDATE TImpMemberCard SET remarks = NULL WHERE remarks = '' SELECT * FROM TImpMemberCard WHERE remarks IS NOT NULL AND FDeleted = 0 SELECT COUNT(*) FROM TImpMemberCard WHERE remarks IS NULL AND FDeleted = 0 UPDATE TImpMemberCard SET FMemo = remarks UPDATE A SET A.FPoint = B.balanceIntegral FROM TImpMember AS B,TMember AS A WHERE A.FMemId = B.FMemId SELECT * FROM TMember WHERE FPoint != 0 INSERT TMemberPointHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransId,FTransNo,FInAmount,FOutAmount,FBalance,FMemo,FRecordTime) SELECT dbo.FNNewId(),A.FMemId,getdate(),0,1,'DR','Import',0,'',FPoint,0,FPoint,'',getdate() FROM TMember AS A WHERE FPoint != 0 SELECT * FROM TMemberCard WHERE FCardNo like '%.%' AND FCardId IN(SELECT FCardId FROM TMemberCardAccount WHERE FBalance > 0) SELECT * FROM TMemberCard WHERE FCardNo = '0021.2' SELECT * FROM TMemberCard WHERE FCardNo = '0021.1' SELECT SELECT * FROM TMemberCard UPDATE TMemberCardType SET FExpiredDate = null DELETE TMemberCardTypeSub WHERE FCompId = 0 UPDATE TMemberCardType SET FValueType = 1 UPDATE TMemberCard SET FValueType = 1 SELECT * FROM TImpMember