use QingDao_HaiDiHui SELECT * FROM TBizLog SELECT * FROM TConsumeBill PDeleteConsumeBill 5378409152833492545 PClearMemberData SELECT * FROM VIP卡 SELECT VIP卡号,SUM(合计金额) FROM 储值记录 GROUP BY VIP卡号 ALTER TABLE VIP卡 ADD FCourseId BIGINT ALTER TABLE VIP卡 ADD FItemId BIGINT ALTER TABLE VIP卡 ADD FMemId BIGINT ALTER TABLE VIP卡 ADD FMemNo VARCHAR(50) ALTER TABLE VIP卡 ADD FCardTypeId BIGINT ALTER TABLE VIP卡 ADD FName VARCHAR(50) ALTER TABLE VIP卡 ADD FMobile VARCHAR(50) ALTER TABLE VIP卡 ADD FMemo VARCHAR(1000) ALTER TABLE VIP卡 ALTER COLUMN FMemo VARCHAR(8000) ALTER TABLE VIP卡 ADD FBirthday DATETIME ALTER TABLE VIP卡 ADD FCreateDate DATETIME ALTER TABLE VIP卡 ADD FIsCourse BIT ALTER TABLE VIP卡 ADD FCompId BIGINT ALTER TABLE VIP卡 ADD FBirhtday DATETIME ALTER TABLE VIP卡 ADD FPW VARCHAR(50) ALTER TABLE VIP卡 ADD FGender INT ALTER TABLE VIP卡 ADD FBriefCode VARCHAR(50) ALTER TABLE VIP卡 ADD FExpiredDate VARCHAR(100) ALTER TABLE VIP卡 ADD FBalance DECIMAL(18,6) ALTER TABLE VIP卡 ADD FRemainTimes DECIMAL(18,6) ALTER TABLE VIP卡 ADD FCardId BIGINT ALTER TABLE VIP卡 ADD FCardState INT ALTER TABLE VIP卡 ADD FCalcMode INT ALTER TABLE VIP卡 ADD FValueType INT ALTER TABLE VIP卡 ADD FState INT ALTER TABLE VIP卡 ADD FDeleted BIT SELECT * FROM VIP卡 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(),'老系统卡' +CAST(折扣 * 10 AS VARCHAR) + '折' , '老系统卡' + CAST(折扣 * 10 AS VARCHAR)+ '折',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 VIP卡 WHERE '老系统卡' +CAST(折扣 * 10 AS VARCHAR) + '折' NOT IN(SELECT FName FROM TMemberCardType ) GROUP BY 折扣 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) select * from 储值记录 ORDER BY 时间 desc drop table 储值记录 where vip卡号= '885228' UPDATE VIP卡 SET FMemId = dbo.FNNewId() UPDATE VIP卡 SET FCardId = dbo.FNNewId() UPDATE VIP卡 SET FMemNO = CAST(VIP卡号 AS BIGINT) UPDATE VIP卡 SET FName = ISNULL(姓名 ,'') UPDATE VIP卡 SET FGender = CASE WHEN 性别 = '男' THEN 1 ELSE 0 END UPDATE VIP卡 SET FBalance = (SELECT SUM(cast(合计金额 as float)) FROM 储值记录 WHERE 储值记录.VIP卡号 = VIP卡.VIP卡号) UPDATE VIP卡 SET FMobile = ISNULL(手机,'') UPDATE VIP卡 SET FMobile = ISNULL(电话,'') WHERE FMobile = '' UPDATE VIP卡 SET FCreateDate = 建卡时间 UPDATE VIP卡 SET FExpiredDate = DATEADD(YEAR,100,FCreateDate) UPDATE VIP卡 SET FCompiD = 1 UPDATE VIP卡 SET FMemo = ISNULL(备注,'') UPDATE VIP卡 SET FState = 1 UPDATE A SET A.FCardTypeId = B.FId, A.FValueType = B.FValueType FROM VIP卡 AS A,TMemberCardType AS B WHERE '老系统卡' + CAST(折扣 * 10 AS VARCHAR)+ '折' = B.FName SELECT FMemNo FROM VIP卡 GROUP BY FMemNo Having sum(1) > 1 UPDATE TMember SET FBriefCode = dbo.FNGetFirstPinYin(FName) --插入会员 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, dbo.FNGetFirstPinYin(FName), 0 AS FTypeId, FCompId, FCreateDate, FGender, 'G' AS FBirthdayType, FBirthday, '' AS FTelephone, FMobile , '' 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 VIP卡 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, FState AS FState, FCreateDate AS FCreateDate, FExpiredDate AS FExpiredDate, ISNULL(FRemainTimes,0) AS FTotalTimes, 0 AS FUsedTimes, 0 AS FSaleCompId, 0 AS FSaleBillId, ISNULL(FMemo,'') AS FMemo FROM VIP卡 delete TMemberCardAccount delete TMemberCardAcctHist 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 VIP卡 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,VIP卡 AS D where C.FCardId = A.FCardId AND C.FCardId = D.FCardId --- end --- end declare @sql varchar(8000) select @sql ='' SELECT @sql = @sql + ' exec sp_rename ''' + a.name + '.[' + b.name + ']'',' + replace(b.name,'"','') from sysobjects as a,syscolumns as b where a.id = b.id and a.name = '消费明细' exec (@sql) ALTER TABLE 消费 ADD FMemId BIGINT ALTER TABLE 消费 ADD FCompId BIGINT ALTER TABLE 消费 ADD FCardId BIGINT ALTER TABLE 消费 ADD FId BIGINT UPDATE A SET A.FCompId = B.FCompId, A.FMemId = B.FMemId, A.FCardId = B.FCardId, A.FId= dbo.FNnewId() FROM VIP卡 AS B,消费 AS A WHERE A.卡号 = B.vip卡号 INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo) SELECT A.FId,A.FMemId,时间,A.FCardId,A.FCompId,'DR','Import','',b.名称,cast(b.单价 as float),1,cast(b.金额 as float),ISNULL(美发师,'') + ',' + ISNULL(助理,'') ,'',ISNULL(备注,'') FROM 消费 AS A,消费明细 as b WHERE a.消费Id = b.消费id and a.FMemId is not null ALTER TABLE 储值记录 ADD FMemId BIGINT ALTER TABLE 储值记录 ADD FCompId BIGINT ALTER TABLE 储值记录 ADD FCardId BIGINT ALTER TABLE 储值记录 ADD FId BIGINT UPDATE A SET A.FCompId = B.FCompId, A.FMemId = B.FMemId, A.FCardId = B.FCardId, A.FId= dbo.FNnewId() FROM VIP卡 AS B,储值记录 AS A WHERE A.vip卡号 = B.vip卡号 INSERT TMemberOldTransHist(FId,FMemId,FTime,FCardId,FCompId,FBillType,FBizType,FTransNo,FContent,FPrice,FQuantity,FAmount,FPayment,FEmployee,FMemo) SELECT FId,A.FMemId,时间,A.FCardId,A.FCompId,'DR','Import','',类别,cast(金额 as decimal(18,6)),1,cast(金额 as decimal(18,6)),ISNULL(美发师,'') + ',' + ISNULL(助理,'') ,'',ISNULL(备注,'') FROM 储值记录 AS A SELECT * FROM VIP卡 WHERE VIP卡号= '885023' SELECT * FROM 储值记录 WHERE VIP卡号= '885228' SELECT * FROM 储值记录 ORDER BY 时间 desc