use qingdao_modenglishe SELECT * FROM TMGJMember SELECT *F SELECT count(1) FROM TMGJMember SELECT * FROM TMGJCard SELECT * FROM TMGJMemberHist SELECT * FROM TMGJMemberHistItem SELECT * FROM TMGJEmployee SELECT * FROM TMGJGoods SELECT * FROM TMGJItem SELECT * FROM TMGJItemType SELECT * FROM TMGJGoodsType SELECT * FROM TEmployee SELECT * FROM TMGJEmployee DELETE TEmployee WHERE FId > 0 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,FIntroducer,FAllowSign,FAllowBooking,FContractType,FState,FCreatorId,FCreateDate,FEntryDate,FExpiredDate,FLeaveDate,FDescription,FCustom1,FCustom2,FCustom3,FPrice,FTags) SELECT employeeId,RIGHT('00' + employeeCode,3),employeeName,FEnLname = '',FEnFname = '',FNickname = employeeName,FDeptId = 0, 0,FTechTypeId = 0,FBriefCode = DBO.FNGetFirstPinYin(employeeName),FGender = 0, FStature = 0,FWeight = 0,FNationPlace = 0,FNation = 0,FEducation = '',FMarital = '',FAddress = '', FTelephone = '',FMobilePhone = '',FQQ = '',FEmail = '',FIdCard = '',FBirthdayType = 'L',FBirthday = NULL, FCardNo = '',FCardPW = '',FPW ='',FBank = '',FBankCardNo = '',FSSNo = '',FHCNo ='',FLinkMan = '', FLinkManTel = '',FLinkManAddr = '',FIntroducer = '' ,FAllowSign = 0,FAllowBooking = 1,FContractType = '', FState = 1,FCreatorId = 0,FCreateDate = GETDATE(),FEntryDate = null,FExpiredDate = null,FLeaveDate = null, FDescription = '',FCustom1 = '',FCustom2 = '',FCustom3 ='',FPrice = 0,FTags = '' FROM TMGJEmployee WHERE employeeName != '阿豪老师' INSERT TEmployeeSub(FEmpId,FCompId,FSerIAlNo) SELECT FId,1,FNo FROM TEMployee INSERT INTO TGoods(FId,FNo,FName,FNoOfPad,FTypeId,FBriefCode,FUnitId,FSalePrice,FPurCostPrice,FSaleCostPrice,FConsCostPrice,FValuationMode,FBarCode,FEnabled,FSpecification,FPurUnitId,FConsUnitId,FSupplierId,FStoreId,FConsStoreId,FSaleStoreId,FMaxStock,FMinStock,FPeriodEnabled,FShelfLife,FDctId,FPointMode,FPointValue,FDeptId,FIsSale,FUnitLock,FDescription,FCustom1,FCustom2,FCustom3) SELECT productId,productCode,productName,productCode,categoryId,dbo.FNGetFirstPinYin(productName), (SELECT FId FROM TBasicType AS A WHERE A.FName = B.UNIT),cast(price as decimal(18,6)),FPurCostPrice = 0,FSaleCostPrice = 0,FConsCostPrice = 0, FValuationMode = 0,FBarCode = barcode,FEnabled = 1,FSpecification = '', FPurUnitId = 0,FConsUnitId = 0,FSupplierId = 0,FStoreId = 0,FConsStoreId= 0,FSaleStoreId= 0, FMaxStock= 0,FMinStock= 0,FPeriodEnabled= 0,FShelfLife= 0,FDctId= 0,FPointMode= 0,FPointValue= 0, FDeptId= 0,FIsSale = 1,FUnitLock= 0,FDescription= '',FCustom1 = '',FCustom2 = '',FCustom3 = '' FROM TMGJGoods AS B SELECT * FROM TGoods UPDATE TMGJGoods SET productCode = productCode + '_' + cast(productId AS VARCHAR) WHERE productCode IN( SELECT productCode FROM TMGJGoods group by productCode having(count(1) > 1)) DELETE TItem WHERE FId > 0 DELETE TItemSub INSERT TItem(FId,FNo,FNoOfPad,FName,FAbbr,FTypeId,FBriefCode,FDescription,FPriceMode,FIsService,FStatTimes,FCustom1,FCustom2,FCustom3,FEnabled,FPrice,FVipPrice,FTime,FDctId,FDisplayTypeId,FPointMode,FPointValue,FDeptId,FAllowBooking) SELECT typeId,code,code,typeName,typeName,parentId,FBriefCode = dbo.FNGetFirstPinYin(typeName), FDescription = '',FPriceMode = 0,FIsService = 1,FStatTimes = 1,FCustom1 = '',FCustom2 = '', FCustom3 = '',FEnabled = 1,price ,FVipPrice = price ,FTime = 0,FDctId = 0 ,FDisplayTypeId = 0, FPointMode = 0,FPointValue = 0,FDeptId = 0,FAllowBooking = 1 FROM TMGJItem UPDATE TItem SET FNo = RIGHT('000' + FNo,3) WHERE LEN(Fno ) < 3 UPDATE TMGJItem SET code = code + '_' + cast(typeId AS VARCHAR) WHERE code IN( SELECT code FROM TMGJItem GROUP BY code HAVING(SUM(1) > 1)) SELECT * FROM TMGJItem WHERE code = '710' SELECT code FROM TMGJItem GROUP BY code HAVING(SUM(1) > 1) SELECT * FROM TMGJItem SELECT * FROM TMGJItemType SELECT * FROM TBasicType WHERE FKey = 'ITEMtYPE' DELETE TBasicType WHERE FKey = 'ITEMtYPE' DELETE TBasicTypeSub WHERE FBasicTypeId IN(SELECT FId FROM TBasicType WHERE FKey = 'ITEMtYPE') DELETE TBasicType WHERE FKey = 'GoodsType' DELETE TBasicTypeSub WHERE FBasicTypeId IN(SELECT FId FROM TBasicType WHERE FKey = 'GoodsType') INSERT TBasicType(FId,FNo,FKey,FName) SELECT categoryId ,categoryId,'ItemType',categoryName FROM TMGJItemType INSERT TBasicType(FId,FNo,FKey,FName) SELECT categoryId ,categoryId,'GoodsType',categoryName FROM TMGJGoodsType ALTER TABLE TMGJCard ADD memId VARCHAR(100) SELECT * INTO TMember_SD FROM TMember SELECT * INTO TMemberCard_SD FROM TMemberCard SELECT * INTO TMemberCardAccount_SD FROM TMemberCardAccount SELECT * INTO TMemberCardAcctHist_SD FROM TMemberCardAcctHist SELECT * INTO TMemberTransHist_SD FROM TMemberTransHist DROP TABLE TMemberCardAcctHist_SD DELETE TMemberCardAcctHist DELETE TMemberCardAccount DELETE TMemberCard WHERE FCardid > 0 DELETE TMember WHERE FMemId > 0 DELETE TMember SELECT ' DELETE ' + NAME FROM sysobjects WHERE name like 'TMemberSale%' SELECT * FROM TMGJCardType DROP TABLE TMGJCardType SELECT * FROM TMGJMember SELECT * FROM TMGJCard select DATEADD(second,cast(createtime as bigint) / 1000,'1970-01-01 00:00:00') FROM TMGJCard ORDER BY createtime desc ALTER TABLE TMGJMember ADD FMemId BIGINT ALTER TABLE TMGJMember ADD FCardNo VARCHAR(50) ALTER TABLE TMGJMember ADD FMemNo VARCHAR(50) ALTER TABLE TMGJMember ADD FName VARCHAR(50) ALTER TABLE TMGJMember ADD FGender INT ALTER TABLE TMGJMember ADD FMobile VARCHAR(50) ALTER TABLE TMGJMember ADD FCardTypeId BIGINT ALTER TABLE TMGJMember ADD FCourseId BIGINT ALTER TABLE TMGJMember ADD FBalance DECIMAL(18,6) ALTER TABLE TMGJMember ADD FBalance2 DECIMAL(18,6) ALTER TABLE TMGJMember ADD FRemainTimes INT ALTER TABLE TMGJMember ADD FPurTimes INT ALTER TABLE TMGJMember ADD FPurAmount DECIMAL(18,6) ALTER TABLE TMGJMember ADD FItemId BIGINT ALTER TABLE TMGJMember ADD FCreateDate DATETIME ALTER TABLE TMGJMember ADD FExpiredDate DATETIME ALTER TABLE TMGJMember ADD FCompId BIGINT ALTER TABLE TMGJMember ADD FCardId BIGINT ALTER TABLE TMGJMember ADD FMemo VARCHAR(1000) ALTER TABLE TMGJMember ADD FArrear DECIMAL(18,6) ALTER TABLE TMGJMember ADD FPoint DECIMAL(18,6) ALTER TABLE TMGJMember ADD FBirthday DATETIME ALTER TABLE TMGJMember ADD FBirthdayType CHAR ALTER TABLE TMGJMember ADD FCustom1 VARCHAR(100) ALTER TABLE TMGJCard ADD FMemId BIGINT ALTER TABLE TMGJCard ADD FCardNo VARCHAR(50) ALTER TABLE TMGJCard ADD FMemNo VARCHAR(50) ALTER TABLE TMGJCard ADD FName VARCHAR(50) ALTER TABLE TMGJCard ADD FGender INT ALTER TABLE TMGJCard ADD FMobile VARCHAR(50) ALTER TABLE TMGJCard ADD FCardTypeId BIGINT ALTER TABLE TMGJCard ADD FCourseId BIGINT ALTER TABLE TMGJCard ADD FBalance DECIMAL(18,6) ALTER TABLE TMGJCard ADD FBalance2 DECIMAL(18,6) ALTER TABLE TMGJCard ADD FRemainTimes INT ALTER TABLE TMGJCard ADD FPurTimes INT ALTER TABLE TMGJCard ADD FPurAmount DECIMAL(18,6) ALTER TABLE TMGJCard ADD FItemId BIGINT ALTER TABLE TMGJCard ADD FCreateDate DATETIME ALTER TABLE TMGJCard ADD FExpiredDate DATETIME ALTER TABLE TMGJCard ADD FCompId BIGINT ALTER TABLE TMGJCard ADD FCardId BIGINT ALTER TABLE TMGJCard ADD FMemo VARCHAR(1000) ALTER TABLE TMGJCard ADD FArrear DECIMAL(18,6) ALTER TABLE TMGJCard ADD FPoint DECIMAL(18,6) ALTER TABLE TMGJCard ADD FBirthday DATETIME ALTER TABLE TMGJCard ADD FBirthdayType CHAR ALTER TABLE TMGJCard ADD FCustom1 VARCHAR(100) --重复 SELECT FCardNo into #Card FROM TMGJCard GROUP BY FCardNo HAVING(SUM(1)) > 1 ALTER TABLE TMGJCard ADD FSeq INT IDENTITY ALTER TABLE TMGJCard ADD FIndex INT UPDATE A SET A.FIndex = 1+(SELECT COUNT(1) FROM TMGJCard AS B WHERE A.FCardNo = B.FCardNo AND (A.FCreateDate > B.FCreateDate OR (A.FCreateDate = B.FCreateDate AND (A.FSeq > B.FSeq) ))) FROM TMGJCard AS A SELECT * FROM TMGJCard WHERE FCardNo IN(SELECT FCardNO FROM #Card) AND FIndex > 0 order by FCardNo UPDATE TMGJCard SET FCardNo = FCardNo + '.' + CAST(FIndex AS VARCHAR) WHERE FCardNo IN( SELECT FCardNo FROM #Card) --会员编号 UPDATE A SET A.FMemNo = B.FCardNo FROM TMGJMember AS A,TMgjCard AS B WHERE A.Id = b.custId UPDATE TMGJMember SET FMemId= id WHERE FMemId Is null UPDATE TMGJMember SET FName = name UPDATE TMGJMember SET FCompId = 1 UPDATE TMGJMember SET FMobile = phone UPDATE TMGJMember SET FGender = case when gender = 'F' then 0 else 1 end UPDATE TMGJMember SET FCreateDate = DATEADD(second,cast(createtime as bigint) / 1000,'1970-01-01 00:00:00') UPDATE TMGJMember SET FBirthday = DATEADD(second,cast(Birthday as bigint) / 1000,'1970-01-01 00:00:00') UPDATE TMGJMember SET FBirthdayType = 'G' --卡 UPDATE TMGJCard SET FCardId = NULL UPDATE TMGJCard SET FCardID = id WHERE FCardId IS NULL UPDATE TMGJCard SET FCardNo = cardNO UPDATE A SET A.FMemId = B.FMemId FROM TMGJCard AS A,TMGJMember AS B WHERE A.custId = B.id --卡类别 UPDATE A SET A.FCardTypeId = C.FId FROM TMGJCardType AS B,TMGJCard AS A,TMemberCardType AS C WHERE A.cardTypeId = b.Id AND 'MGJ' + b.cardCode = C.FNo --余额 UPDATE TMGJCard SET FBalance = balance UPDATE TMGJCard SET FCompId = 1 UPDATE TMGJCard SET FCreateDate = DATEADD(second,cast(createtime as bigint) / 1000,'1970-01-01 00:00:00') UPDATE TMGJCard SET FExpiredDate = DATEADD(year,100,FCreateDate) SELECT * FROM TMGJCard SELECT * FROM TMGJMember WHERE FMemNO IN(SELECT FMemNO FROM TMember) UPDATE TMGJMember SET FMemNo = 'A' + FMemNo WHERE FMemNo IN(SELECT FMemNo FROM TMember) UPDATE TMGJCard SET FCardNo = 'A' + FCardNo WHERE FCardNo IN(SELECT FCardNo FROM TMembercARD) 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 TMGJMember 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 TMGJCard 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 TMGJCard AS A 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 TMGJCard AS A 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 =id,'MGJ' + cardCode,cardCode as name,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 TMGJCardType 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 id FROM TMGJCardType) AND C.FId = dbo.FNCompId('007') AND NOT EXISTS(SELECT TOP 1 1 FROM TMemberCardTypeSub AS B WHERE B.FCompId = C.FId AND B.FCardTypeId = I.FId)