SELECT * FROM TImpMember3 SELECT * FROM TImpMember3 WHERE CUSTNO NOT IN (SELECT CUSTNO FROM TImpMember) SELECT * INTO TImpMember FROM JiMo_AiDingBao_MeiShow..TImpMember SELECT * INTO card FROM JiMo_AiDingBao_MeiShow..card SELECT * INTO cardType FROM JiMo_AiDingBao_MeiShow..cardType SELECT * FROM TImpMember SELECT * FROM TImpMember DROP TABLE TImpMember --会员 ALTER TABLE TImpMember ADD FMemId BIGINT NOT NULL DEFAULT 0 ALTER TABLE TImpMember ADD FMemNo VARCHAR(50) NOT NULL DEFAULT '' ALTER TABLE TImpMember ADD FName VARCHAR(50) NOT NULL DEFAULT '' ALTER TABLE TImpMember ADD FGender INT NOT NULL DEFAULT 0 ALTER TABLE TImpMember ADD FMobile VARCHAR(50) NOT NULL DEFAULT '' ALTER TABLE TImpMember ADD FMemo VARCHAR(1000) DEFAULT '' ALTER TABLE TImpMember ADD FArrear DECIMAL(18,6) DEFAULT 0 ALTER TABLE TImpMember ADD FPoint DECIMAL(18,6) DEFAULT 0 ALTER TABLE TImpMember ADD FBirthday DATETIME ALTER TABLE TImpMember ADD FBirthdayType CHAR NOT NULL DEFAULT '' ALTER TABLE TImpMember ADD FCreateDate DATETIME ALTER TABLE TImpMember ADD FExpiredDate DATETIME ALTER TABLE TImpMember ADD FCompId BIGINT DEFAULT 0 ALTER TABLE TImpMember ADD FDeleted BIT NOT NULL DEFAULT 0 ALTER TABLE TImpMember ADD FPassword VARCHAR(1000) DEFAULT '' SELECT * FROM TImpMember ALTER TABLE TImpMember ADD FCardNo VARCHAR(50) NOT NULL DEFAULT '' ALTER TABLE TImpMember ADD FCardTypeId BIGINT NOT NULL DEFAULT 0 ALTER TABLE TImpMember ADD FBalance DECIMAL(18,6) NOT NULL DEFAULT 0 ALTER TABLE TImpMember ADD FRemainTimes INT NOT NULL DEFAULT 0 ALTER TABLE TImpMember ADD FCompId BIGINT NOT NULL DEFAULT 0 ALTER TABLE TImpMember ADD FCardId BIGINT NOT NULL DEFAULT 0 ALTER TABLE TImpMember ADD FMemId BIGINT NOT NULL DEFAULT 0 ALTER TABLE TImpMember ADD FCreateDate DATETIME ALTER TABLE TImpMember ADD FExpiredDate DATETIME ALTER TABLE TImpMember ADD FPoint DECIMAL(18,6) NOT NULL DEFAULT 0 ALTER TABLE TImpMember ADD FPassword VARCHAR(50) NOT NULL DEFAULT '' ALTER TABLE TImpMember ADD FMemo VARCHAR(1000) NOT NULL DEFAULT '' ALTER TABLE TImpMember ADD FDeleted BIT NOT NULL DEFAULT 0 ALTER TABLE TImpMember ADD FState INT NOT NULL DEFAULT 1 --会员资料 SELECT SUM(余额) FROM TImpMember WHERE 余额 IS NOT NULL SELECT * FROM TImpMember WHERE FDeleted = 0 AND replace(状态,' ','') not like '%启用%' UPDATE TImpMember SET FDeleted = 0 UPDATE TImpMember SET FDeleted = 1 WHERE 状态说明 = '退卡-3' UPDATE TImpMember SET FState = 16 WHERE 状态说明 = '挂失-2' SELECT * FROM TImpMember WHERE replace(状态,' ','') not like '%启用%' DELETE TImpMember WHERE 会员卡号 IS NULL --没有卡的会员,标记为删除 UPDATE TImpMember SET FDeleted = 1 WHERE Id NOT IN(SELECT TImpMemberId FROM TImpMember WHERE FDeleted = 0) --门店 UPDATE TImpMember SET FCompId = 1 --会员ID UPDATE TImpMember SET FMemId = 会员卡号 UPDATE TImpMember SET FCardId = 会员卡号 UPDATE TImpMember SET FMemNo = 会员卡号 UPDATE TImpMember SET FCardNo = 会员卡号 --姓名 UPDATE TImpMember SET FName = 姓名 --电话 UPDATE TImpMember SET FMobile = ISNULL(联系电话,'') --性别 UPDATE TImpMember SET FGender = case when 性别 = '男' THEN 1 ELSE 0 END --CreateDate UPDATE TImpMember SET FCreateDate = 创建日期 --备注 UPDATE TImpMember SET FExpiredDate = '2116-01-01' --生日 UPDATE TImpMember SET FBirthday = 出生日期 UPDATE TImpMember SET FBirthdayType = 'G' --余额 UPDATE TImpMember SET FBalance = isnull(余额,0) UPDATE TImpMember SET FPoint = isnull(积分,0) UPDATE A SET A.FBalance = B.FBalance FROM TMemberCardAcctHist AS A,TImpMember AS B WHERE A.FCardId = B.FCardId --类别 UPDATE A SET A.FCardTypeId = B.FId FROM TIMpMember AS A,TMemberCardType AS B WHERE A.卡类型= b.fname --卡 SELECT * FROM TImpMember --删除 UPDATE TImpMember SET FDeleted = Deleted UPDATE TImpMember SET FDeleted = 1 WHERE bChain = 1 --门店 UPDATE TImpMember SET FCompId = 1 --卡ID UPDATE TImpMember SET FCardId = 100000 + Id --会员ID UPDATE TImpMember SET FMemId = TImpMemberId + 100000 --类别 UPDATE TImpMember SET FCardTypeId = 1000 + TypeId --卡号 UPDATE TImpMember SET FCardNO = ContextId --积分 UPDATE TImpMember SET FPoint = CardPoint --开卡日期 UPDATE TImpMember SET FCreateDate = SellDate --有效期 UPDATE TImpMember SET FExpiredDate = OutDate --密码 UPDATE TImpMember SET FPassword = ISNULL(Password,'') --备注 UPDATE TImpMember SET FMemo = ISNULL(Remark,'') select * from TImpMember where FMemNo = '' AND FDeleted = 0 select * from card where TImpMemberId = 1459 SELECT * FROM TImpMember WHERE FCardNo = '01302' SELECT * FROM TImpMember WHERE FMemId = 100428 SELECT * FROM TImpMember WHERE FMemId = 101459 SELECT * FROM TConsumeBill select * from TImpMember where fmemno = '' AND FDeleted = 0 SELECT * FROM SELECT FMemNO,sum(1) FROM TImpMember WHERE FDeleted = 0 GROUP BY FMemNo HAVING(SUM(1) > 1) SELECT A.FName,A.FMobile,* FROM TImpMember AS B,TImpMember AS A WHERE B.FCardNo in( SELECT FCardNo FROM TImpMember WHERE FDeleted = 0 --AND bChain = 0 GROUP BY FCardNo HAVING(SUM(1) > 1) ) AND B.FDeleted = 0 AND A.FDeleted= 0 AND A.FMemId = B.FMemId ORDER BY FCardNo SELECT * FROM TImpMember WHERE TImpMemberId = 10518 SELECT * FROM TImpMember WHERE TImpMemberId = 12281 SELECT * FROM TImpMember WHERE FMemNo = '00758' SELECT * FROM TImpMember WHERE FCardNo = '02218' SELECT * FROM TImpMember WHERE bChain = 1 SELECT * FROM CardType WHERE id IN( 47,36) SELECT 卡类型 FROM TImpMember GROUP BY 卡类型 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, 'G' AS FBirthdayType, FBirthday AS FBirthday, '' AS FTelephone, ISNULL(FMobile,'') AS FMobilePhone, '' AS FQQ, '' AS FWeChat, '' AS FIdCard, '' AS FEmail, '' AS FAddress, 0 AS FProId, ISNULL(FPassword,'') AS FCPW, '' AS FQPW, 0 AS FChargeEmpId, ISNULL( FPoint,0) AS FPoint, 1 AS FRecvConsSMS, 1 AS FRecvBulkSMS, ISNULL(FMemo,'') AS FMemo, '' AS FCustom1,'' AS FCustom2,'' AS FCustom3,'' AS FCustom4,'' AS FCustom5 from TImpMember WHERE FDeleted = 0 UPDATE TImpMember SET FMemno = 'M' + FMemno WHERE FMemno IN(SELECT FMemno FROM TMember) UPDATE card SET FCardNo = 'M' + FCardNo WHERE FCardNo IN(SELECT FCardNO FROM TMemberCard) 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, FState AS FState, ISNULL(FCreateDate,1900) AS FCreateDate, FExpiredDate, 0 AS FTotalTimes, 0 AS FUsedTimes, FCompId AS FSaleCompId, 0 AS FSaleBillId, '' AS FMemo FROM TImpMember WHERE FDeleted = 0 GROUP BY FCardNo,FCardTypeId,FCompId ,FMemId,FExpiredDate,FCreateDate,FCardId WHERE FCardTypeId 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,DATEADD(year,1, FCreateDate) AS FExpiredDate,'' FROM TImpMember 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 TImpMember AS A WHERE FDeleted = 0 UPDATE TMemberCardAcctHist SET FMemo = '' SELECT * FROM TImpTransLog WHERE 客户编号 = 'A020935' update A SET A.FMemId SELECT * FROM TMemberCard WHERE FId = 5494058162892437466 UPDATE A SET A.FExpiredDate = B.FExpiredDate FROM TMemberCard AS A,TImpMember3 AS B WHERE A.FCardId = B.FCardId SELECT * FROM TImpMember3 UPDATE A SET A.FMemo = B.Rem FROM TMemberCard AS A,TImpMember3 AS B WHERE A.FCardId = B.FCardId AND B.Rem IS NOT NULL SELECT * FROM TMemberCardType UPDATE TMemberCardType SET FId = FNo + 1000 WHERE FId > 0 UPDATE TMemberCard SET FTypeId = 0 DELETE TMemberCardTypeSUB UPDATE A SET A.FTypeId = B.CType + 1000 FROM TMemberCard AS A,TImpMember3 AS B WHERE A.FCardId = B.FCardId UPDATE TImpMember3 SET FCardTypeId = CType + 1000 SELECT * FROM TMemberCard WHERE FMemo != '' delete TImpMember3 where CUSTNO IN(SELECT CUSTNO FROM TImpMember2) SELECT * FROM fs.SaiDao_AppServer.dbo.TClient SELECT * FROM card WHERE TImpMemberId = 273 SELECT TImpMemberId ,SUM(1) FROM card WHERE FDeleted = 0 GROUP BY TImpMemberId HAVING(SUM(1) > 1) SELECT * FROM card WHERE TImpMemberId = 0 AND Deleted = 0 SELECT * FROM CardType WHERE Deleted = 0 AND Id NOT IN(SELECT TypeId FROM card WHERE Deleted = 0) SELECT * FROM fs.QingDao_DieQiao.dbo.TMemberCardType ---卡类别 INSERT TMemberCardType(FId,FNo,FName,FValueType,FMaterial,FPrice,FAcctId,FDeposit,FAcctId2,FDeposit2,FAcctId3,FDeposit3,FTimes,FAlertBalance,FMinRchgAmt,FValidityPeriod,FValidityPeriodUnit,FAllowSale,FAllowRchg,FOrder,FSalePointMode,FSalePointValue,FRchgPointMode,FRchgPointValue,FEnabled) SELECT FId = dbo.FNNewId(), FNo = 卡类型, FName = 卡类型, 1 AS FValueType, 2 AS FMaterial, 0 AS FPrice, 3 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 FMinRchgAmt, 0 AS FValidityPeriod, 0 AS FValidityPeriodUnit, 1 AS FAllowSale, 1 AS FAllowRchg, 1, 0 AS FSalePointMode, 0 AS FSalePointValue, 0 AS FRchgPointMode, 0 AS FRchgPointValue, 1 AS FEnabled FROM TImpmember GROUP BY 卡类型 --项目类别 SELECT * FROM ServiceType INSERT TBasicType(FId,FKey,FNo,FName) SELECT 100000 + Id,'ItemType',Id,Name FROM ServiceType --项目 SELECT * FROM Service 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) SELECT Id+1000,Id,Id,Name,Name,TypeId + 100000,dbo.FNGetFirstPinYin(Name),'''',1,1,1,'''','''','''',1,Price,Price,0,0,1,0,0,1 FROM Service --员工 --职位 INSERT TBasicType(FId,FKey,FNo,FName) SELECT 200000 + id,'Position',Id,Name FROM job INSERT INTO TEmployee(FId,FNo,FName,FEnLname,FEnFname,FNickname,FDeptId,FPosId,FTechTypeId,FBriefCode,FGender,FStature,FWeight,FNationPlace,FNation,FEducation,FMarital,FAddress,FTelephone,FMobilePhone,FQQ,FEmail,FIdCard,FBirthdayType,FBirthday,FCardNo,FCardPW,FPW,FBank,FBankCardNo,FSSNo,FHCNo,FLinkMan,FLinkManTel,FLinkManAddr,FIntrId,FAllowSign,FAllowBooking,FContractType,FState,FCreatorId,FCreateDate,FEntryDate,FExpiredDate,FLeaveDate,FDescription,FCustom1,FCustom2,FCustom3) SELECT 1000+ id,ContextId,Name,'','',NickName,0,JobId + 200000,0,dbo.FNGetFirstPinYin(name),sex,0,0,'','','','',FamilyAddress,'',Phone,'','',Identiy,'G',Birth,'','','','','','','',FamilyName,FamilyTel,'',0,0,1,0,1,0,AddDate,AddDate,NULL,OutDate,'','','','' FROM Employee WHERE ContextId NOT LIKE '%离职%' UPDATE TEmployee SET FDeptId = 5523957399072203416 SELECT * FROM Employee SELECT ContextId ,SUM(1) FROM Employee GROUP BY ContextId HAVING(SUM(1) > 1) SELECT * FROM TBasicType WHERE FKey LIKE 'Dep%' DELETE TEmployeeSub INSERT TEmployeeSub(FEmpId,FSerialNo,FCompId) SELECT E.FId,E.FNo,C.FId FROM TEMployee AS E,TCompany AS C WHERE C.FId != 0 AND E.FId != 0