You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
sql-tools/连锁分离单店.sql

61 lines
8.6 KiB

-- -- 查询公司
SELECT * FROM TCompany WHERE FId = '3472333586818924544'
INSERT INTO QingDao_saidao12.dbo.TCompany ([FId] ,[FNo] ,[FName] ,[FAbbr] ,[FAreaId] ,[FParentId] ,[FAddress] ,[FTelephone] ,[FEmail] ,[FWebsite] ,[FWeChatNo] ,[FWeChatQRCode] ,[FAppId] ,[FIntroduction] ,[FAdmin] ,[FIsCenter] ,[FAllowBooking] ,[FDeleted] ,[FDataNameIndex] ,[FWeChatAppNo] ,[FBookingOrder] ,[FLocationLat] ,[FLocationLng] ,[FAvatar] ,[FRegId] ,[FAddressProvince] ,[FAddressCity] ,[FAddressDistrict] ,[FAddressStreet] ,[FAddressDetail] ,[FWindowImages])
SELECT [FId],[FNo],[FName],[FAbbr],[FAreaId],[FParentId],[FAddress],[FTelephone],[FEmail],[FWebsite],[FWeChatNo],[FWeChatQRCode],[FAppId],[FIntroduction],[FAdmin],[FIsCenter],[FAllowBooking],[FDeleted],[FDataNameIndex],[FWeChatAppNo],[FBookingOrder],[FLocationLat],[FLocationLng],[FAvatar],[FRegId],[FAddressProvince],[FAddressCity],[FAddressDistrict],[FAddressStreet],[FAddressDetail],[FWindowImages]
FROM TCompany WHERE FId = '3472333586818924544'
-- 查询公司名下的会员
INSERT INTO QingDao_saidao12.dbo.TMember ([FMemId],[FMemNo],[FName],[FBriefCode],[FCompId],[FTypeId],[FIsVisitor],[FCreateDate],[FExpiredDate],[FGender],[FBirthdayType],[FBirthday],[FTelephone],[FMobilePhone],[FQQ],[FWeChat],[FWXName],[FIdCard],[FEmail],[FAddress],[FProId],[FPlateNo],[FDriverLicense],[FVehicleLicense],[FInsurer],[FCPW],[FPWReset],[FQPW],[FValidationMode],[FIntrId],[FChargeEmpId],[FPoint],[FLevelId],[FRecvConsSMS],[FRecvBulkSMS],[FMemo],[FCustom1],[FCustom2],[FCustom3],[FCustom4],[FCustom5],[FState],[FDeleted]) SELECT [FMemId],[FMemNo],[FName],[FBriefCode],[FCompId],[FTypeId],[FIsVisitor],[FCreateDate],[FExpiredDate],[FGender],[FBirthdayType],[FBirthday],[FTelephone],[FMobilePhone],[FQQ],[FWeChat],[FWXName],[FIdCard],[FEmail],[FAddress],[FProId],[FPlateNo],[FDriverLicense],[FVehicleLicense],[FInsurer],[FCPW],[FPWReset],[FQPW],[FValidationMode],[FIntrId],[FChargeEmpId],[FPoint],[FLevelId],[FRecvConsSMS],[FRecvBulkSMS],[FMemo],[FCustom1],[FCustom2],[FCustom3],[FCustom4],[FCustom5],[FState],[FDeleted] FROM TMember WHERE FCompId = '3472333586818924544'
SELECT * FROM QingDao_saidao12.dbo.TMember WHERE FMemId = '5154277235782509744'
UPDATE QingDao_saidao12.dbo.TMember SET FCompId = '1'
SELECT * FROM TMemberTransHist WHERE FMemId IN (SELECT FMemId FROM TMember WHERE FCompId = '3472333586818924544')
SELECT distinct FTypeId FROM TMemberCard WHERE FCompId = '3472333586818924544'
SELECT * FROM TMemberCardType WHERE FId = '5100645820915463158'
SELECT * FROM QingDao_saidao12.dbo.TMemberCardType
SELECT * FROM QingDao_saidao12.dbo.TMemberCard
SELECT * FROM QingDao_saidao12.dbo.TMemberCardTypeSub
-- 卡类别导入
INSERT INTO QingDao_saidao12.dbo.TMemberCardType ([FId],[FNo],[FName],[FValueType],[FMaterial],[FPrice],[FCardFeeAmt],[FAcctId],[FDeposit],[FAcctId2],[FDeposit2],[FAcctId3],[FDeposit3],[FTimes],[FAlertBalance],[FMinRchgAmt],[FMinSaleAmt],[FSalePointMode],[FSalePointValue],[FRchgPointMode],[FRchgPointValue],[FPaySmsFee],[FTimeCard],[FValidityPeriod],[FValidityPeriodUnit],[FExpiredDate],[FDefaultMemo],[FCreateTime],[FAllowSale],[FAllowRchg],[FAllowUpgrade],[FDeptId],[FEnabled],[FNeedPush],[FNeedPushTimes],[FNeedPushExpired],[FPopupRemindExpiredDays],[FDisplay],[FLevel],[FOrder],[FDeleted],[FSaleMaxArrear],[FRchgMaxArrear],[FRetainRate],[FNewMemberOnly]) SELECT [FId],[FNo],[FName],[FValueType],[FMaterial],[FPrice],[FCardFeeAmt],[FAcctId],[FDeposit],[FAcctId2],[FDeposit2],[FAcctId3],[FDeposit3],[FTimes],[FAlertBalance],[FMinRchgAmt],[FMinSaleAmt],[FSalePointMode],[FSalePointValue],[FRchgPointMode],[FRchgPointValue],[FPaySmsFee],[FTimeCard],[FValidityPeriod],[FValidityPeriodUnit],[FExpiredDate],[FDefaultMemo],[FCreateTime],[FAllowSale],[FAllowRchg],[FAllowUpgrade],[FDeptId],[FEnabled],[FNeedPush],[FNeedPushTimes],[FNeedPushExpired],[FPopupRemindExpiredDays],[FDisplay],[FLevel],[FOrder],[FDeleted],[FSaleMaxArrear],[FRchgMaxArrear],[FRetainRate],[FNewMemberOnly] FROM TMemberCardType WHERE FId != '0'
-- 卡归属公司
INSERT INTO QingDao_saidao12.dbo.TMemberCardTypeSub ([FId],[FCompId],[FCardTypeId],[FAllowSale],[FAllowRchg],[FEnabled]) SELECT [FId],[FCompId],[FCardTypeId],[FAllowSale],[FAllowRchg],[FEnabled] FROM TMemberCardTypeSub WHERE FCompId = '3472333586818924544'
UPDATE QingDao_saidao12.dbo.TMemberCardTypeSub SET FCompId = '1'
INSERT INTO QingDao_saidao12.dbo.TMemberCard ([FCardId],[FCardNo],[FCardFaceNo],[FTypeId],[FValueType],[FCompId],[FMemId],[FState],[FCreateDate],[FExpiredDate],[FTotalTimes],[FUsedTimes],[FSaleCompId],[FSaleBillId],[FPaySmsFee],[FMemo],[FDeleted],[FBizEmpid]) SELECT [FCardId],[FCardNo],[FCardFaceNo],[FTypeId],[FValueType],[FCompId],[FMemId],[FState],[FCreateDate],[FExpiredDate],[FTotalTimes],[FUsedTimes],[FSaleCompId],[FSaleBillId],[FPaySmsFee],[FMemo],[FDeleted],[FBizEmpid] FROM TMemberCard WHERE FMemId IN (SELECT FMemId FROM TMember WHERE FCompId = '3472333586818924544')
UPDATE QingDao_saidao12.dbo.TMemberCard SET FCompId = '1'
SELECT [FCardId],[FCardNo],[FCardFaceNo],[FTypeId],[FValueType],[FCompId],[FMemId],[FState],[FCreateDate],[FExpiredDate],[FTotalTimes],[FUsedTimes],[FSaleCompId],[FSaleBillId],[FPaySmsFee],[FMemo],[FDeleted],[FBizEmpid] FROM TMemberCard WHERE FMemId IN (SELECT FMemId FROM TMember WHERE FCompId = '3472333586818924544')
-- 会员交易历史
-- 需要的数据:
INSERT INTO QingDao_saidao12.dbo.TMemberTransHist ([FId],[FMemId],[FTime],[FCardId],[FCompId],[FBillType],[FBizType],[FTransId],[FTransNo],[FTransDetailId],[FContentId],[FContentText],[FOrigPrice],[FDctPrice],[FQuantity],[FUnitId],[FAmount],[FPayment],[FEmployee],[FIsVisitor],[FMemo],[FCreatorId],[FRecordTime]) SELECT * FROM TMemberTransHist WHERE FCompId = '3472333586818924544'
UPDATE QingDao_saidao12.dbo.TMemberTransHist SET FCompId = '1'
INSERT INTO QingDao_saidao12.dbo.TMemberOldTransHist ([FId],[FMemId],[FTime],[FCardId],[FCompId],[FBillType],[FBizType],[FTransNo],[FContent],[FPrice],[FQuantity],[FAmount],[FPayment],[FEmployee],[FMemo]) SELECT * FROM TMemberOldTransHist WHERE FCompId = '3472333586818924544'
UPDATE QingDao_saidao12.dbo.TMemberOldTransHist SET FCompId = '1'
SELECT * FROM TMemberOldTransHist WHERE FCompId = '3472333586818924544'
INSERT INTO QingDao_saidao12.dbo.TMemberTransHistPayment ([FMemId],[FCardId],[FBillType],[FTransId],[FTransDetailId],[FHistId],[FPayCardId],[FPayTypeId],[FPayAmt])
SELECT * FROM TMemberTransHistPayment WHERE FMemId in (SELECT distinct FMemId FROM QingDao_saidao12.dbo.TMember)
INSERT INTO QingDao_saidao12.dbo.TMemberCardAcctHist ([FId],[FMemId],[FCardId],[FAcctId],[FTime],[FCardTypeId],[FCompId],[FBillType],[FBizType],[FTransId],[FTransNo],[FInAmount],[FOutAmount],[FBalance],[FArrear],[FRecordTime],[FMemo]) SELECT * FROM TMemberCardAcctHist WHERE FCompId = '3472333586818924544'
UPDATE QingDao_saidao12.dbo.TMemberCardAcctHist SET FCompId = '1'
-- 会员卡账户
INSERT INTO QingDao_saidao12.dbo.TMemberCardAccount ([FId],[FMemId],[FCardId],[FAcctId],[FDeposit],[FBalance],[FArrear],[FCreateDate],[FExpiredDate],[FMemo],[FRetain]) SELECT * FROM TMemberCardAccount WHERE FMemId in (SELECT distinct FMemId FROM QingDao_saidao12.dbo.TMember)
INSERT INTO QingDao_saidao12.dbo.TMemberCardAcctHist ([FId],[FMemId],[FCardId],[FAcctId],[FTime],[FCardTypeId],[FCompId],[FBillType],[FBizType],[FTransId],[FTransNo],[FInAmount],[FOutAmount],[FBalance],[FArrear],[FRecordTime],[FMemo]) SELECT * FROM TMemberCardAcctHist WHERE FMemId in (SELECT distinct FMemId FROM QingDao_saidao12.dbo.TMember)
-- 员工
INSERT INTO QingDao_saidao12.dbo.TEmployee([FId],[FNo],[FShortNo],[FName],[FEnLname],[FEnFname],[FNickname],[FCompId],[FDeptId],[FPosId],[FTechTypeId],[FGroupId],[FBriefCode],[FGender],[FStature],[FWeight],[FNationPlace],[FNation],[FEducation],[FMarital],[FAddress],[FTelephone],[FMobilePhone],[FQQ],[FEmail],[FIdCard],[FBirthdayType],[FBirthday],[FCardNo],[FPW],[FBank],[FBankCardNo],[FSSNo],[FHCNo],[FLinkMan],[FLinkManTel],[FLinkManAddr],[FIsManager],[FAllowBooking],[FBookingCount],[FContractType],[FState],[FCreatorId],[FCreateDate],[FEntryDate],[FExpiredDate],[FLeaveDate],[FIntroduction],[FMemo],[FPrice],[FTags],[FAvatar],[FRoleId],[FDeleted]) SELECT [FId],[FNo],[FShortNo],[FName],[FEnLname],[FEnFname],[FNickname],[FCompId],[FDeptId],[FPosId],[FTechTypeId],[FGroupId],[FBriefCode],[FGender],[FStature],[FWeight],[FNationPlace],[FNation],[FEducation],[FMarital],[FAddress],[FTelephone],[FMobilePhone],[FQQ],[FEmail],[FIdCard],[FBirthdayType],[FBirthday],[FCardNo],[FPW],[FBank],[FBankCardNo],[FSSNo],[FHCNo],[FLinkMan],[FLinkManTel],[FLinkManAddr],[FIsManager],[FAllowBooking],[FBookingCount],[FContractType],[FState],[FCreatorId],[FCreateDate],[FEntryDate],[FExpiredDate],[FLeaveDate],[FIntroduction],[FMemo],[FPrice],[FTags],[FAvatar],[FRoleId],[FDeleted] FROM TEmployee WHERE FId != 0