【脚本】三代门店恢复总部数据,清除其他门店数据。
2018-08-24    耿朋亮
1790 0
用于解决三代印特软件,门店数据丢失,从总部恢复数据的问题。
  • 执行脚本清除其他门店数据

    SET XACT_ABORT on
    Begin Transaction

        Declare @ShopCode bigint
        Set @ShopCode = '门店编号'

        Delete ASM_AssertNumberStatus Where ShopCode<>@ShopCode

        Delete ASM_CounterBill Where ShopCode <> @ShopCode
        Delete ASM_MaintenanceBill Where ShopCode <> @ShopCode
        Delete ASM_NumberBill Where ShopCode <> @ShopCode
        Delete ASM_NumberBillDetail Where ShopCode <> @ShopCode
        Delete ASM_NumberBillWaste Where ShopCode <> @ShopCode
        
        Delete CRM_BonusPointsExchangeBill Where ShopCode <> @ShopCode
        Delete CRM_BonusPointsExchangeBillDetail Where ShopCOde<>@ShopCode
        
        Delete CRM_CardCore
        
        Delete CRM_Customer Where ShopCode <> @ShopCode and IsShare = '0' and ICCardNumbers = 0
        Delete CRM_Linkman Where CustomerCode NOT IN (Select Code From  CRM_Customer)    
        Delete CRM_NegotiatedPrice Where CustomerCode NOT IN (Select Code From  CRM_Customer)

        Delete CRM_FeedbackBill Where ShopCode <> @ShopCode
        
        Delete FAM_Account Where ShopCode <> @ShopCode
        Delete FAM_AccountHistory Where ShopCode <> @ShopCode
        Delete FAM_AccPCalendar Where ShopCode <> @ShopCode
        Delete FAM_CredenceBill Where ShopCode <> @ShopCode
        Delete FAM_CredenceBillDetail Where ShopCode <> @ShopCode
        Delete FAM_IncomingBill Where ShopCode <> @ShopCode
        Delete FAM_InvoiceBill Where ShopCode <> @ShopCode
        Delete FAM_LoanBill Where ShopCode<>@ShopCOde
        Delete FAM_OutgoingBill Where ShopCode <> @ShopCode
        Delete FAM_TransferBill Where ShopCode <> @ShopCode

        Update GSS_BillCoder Set CoderCurDay=1506,CoderAutoCounter=11000

        Update GSS_EMSDB Set ShopCode = Convert(nvarchar(100),@ShopCode),Id=newid() Where Code = '000000'    
        Delete HRM_AttendenceBill Where ShopCode <> @ShopCode
        Delete HRM_AttendenceBillDetail Where ShopCode <> @ShopCode

        Delete HRM_PunishBill Where ShopCode <> @ShopCode
        Delete HRM_PunishBillDetail Where ShopCode <> @ShopCode
        Delete HRM_RewardBill Where ShopCode <> @ShopCode
        Delete HRM_RewardBillDetail Where ShopCode <> @ShopCode

        Delete HRM_User  Where ShopCode<>@ShopCode and ShopCode<>100
        Delete HRM_UserPurview  Where ShopCode<>@ShopCode and ShopCode<>100
        Delete HRM_UserSetting
            
        Delete INM_AllocateBill Where ShopCode<>@ShopCode
        Delete INM_AllocateBillDetail Where ShopCode<>@ShopCode
        
        Delete INM_AntiInBill Where ShopCode <> @ShopCode
        Delete INM_AntiInBillDetail Where ShopCode <> @ShopCode
        Delete INM_CheckBill Where ShopCode <> @ShopCode
        Delete INM_CheckBillDetail Where ShopCode <> @ShopCode
        Delete INM_InBill Where ShopCode <> @ShopCode
        Delete INM_InBillDetail Where ShopCode <> @ShopCode

        Delete INM_MaterialExtend Where ShopCode<>@ShopCode
        Delete INM_MaterialStock Where ShopCode <> @ShopCode
        Delete INM_MaterialStoreHouseSpec Where ShopCode <> @ShopCode
        
        Delete INM_MoveBill Where ShopCode <> @ShopCode
        Delete INM_MoveBillDetail Where ShopCode <> @ShopCode
        Delete INM_OutBill Where ShopCode <> @ShopCode
        Delete INM_OutBillDetail Where ShopCode <> @ShopCode
        Delete INM_PackagingBill Where ShopCode <> @ShopCode
        Delete INM_PackagingBillDetail Where ShopCode <> @ShopCode
        Delete INM_PlanBill Where ShopCode <> @ShopCode
        Delete INM_PlanBillDetail Where ShopCode <> @ShopCode
        Delete INM_UsedBill Where ShopCode <> @ShopCode
        Delete INM_UsedBillDetail Where ShopCode <> @ShopCode
        
        Delete PIM_Logy Where ShopCode <> @ShopCode
        Delete PIM_Mission Where ShopCode <> @ShopCode
        Delete PIM_Note
        Delete PIM_OperationApply
        
        Delete PPM_JobBill Where ShopCode <> @ShopCode
        Delete PPM_JobBillDetail Where ShopCode <> @ShopCode
        Delete PPM_JobBillDetailNumericAssert Where ShopCode <> @ShopCode
        Delete PPM_JobBillDetailUsedMaterial Where ShopCode <> @ShopCode
        Delete PPM_JobBillDetailUserExec Where ShopCode <> @ShopCode

        Delete PPM_LogisticsBill Where ShopCode <> @ShopCode
        Delete PPM_OutSourcingBill Where ShopCode <> @ShopCode
        Delete PPM_InnerSourcingBill Where ShopCode<>@ShopCode AND SupplierCode NOT LIKE '%NX' + Convert(Nvarchar(10),@ShopCode)
        Delete PPM_InnerSourcingBillDetail Where ParentBillCode NOT IN (select Code from PPM_InnerSourcingBill )
        Delete PPM_ProblemBillDetail Where ShopCode <> @ShopCode
        Delete PPM_ProblemBill Where ShopCode <> @ShopCode
        Delete PPM_ProduceFlowRecord Where ShopCode<>@ShopCode
        

        Delete PPM_ProduceSendAndGet Where ShopCode <> @ShopCode
        Delete PPM_ProduceTakeOver Where ShopCode <> @ShopCode
        Delete PPM_UserAssign Where ShopCode <> @ShopCode

        Delete RSM_GatheringBill Where ShopCode <> @ShopCode
        Delete RSM_PettyGatheringBill Where ShopCode <> @ShopCode
        Delete RSM_PreGatheringBill Where ShopCode <> @ShopCode
        Delete RSM_RefundmentBill Where ShopCode <> @ShopCode
        Delete RSM_SettleGatheringBill Where ShopCode <> @ShopCode
        Delete RSM_SettleGatheringBillDetail Where ShopCode <> @ShopCode
        Delete SRM_CashPaymentBill Where ShopCode <> @ShopCode
        Delete SRM_ChargeUpPaymentBill Where ShopCode <> @ShopCode
        Delete SRM_PrePaymentBill Where ShopCode <> @ShopCode
        Delete SRM_SettlePaymentBill Where ShopCode <> @ShopCode
        Delete SRM_SettlePaymentBillDetail Where ShopCode <> @ShopCode    

        Delete SMM_PriceBill Where ShopCode<>@ShopCode
        Delete SMM_PriceBillDetail Where ShopCode<>@ShopCode

        Delete SMM_SaleOpportunity Where ShopCode <>@ShopCode
        Delete SMM_SaleOpportunityDemand Where ShopCode <>@ShopCode
        Delete SMM_SaleOpportunityStage Where ShopCode <>@ShopCode

        Delete SRM_Supplier Where ShopCode <> @ShopCode    
        Delete SRM_SupplierBusiness Where SupplierCode NOT In (Select Code From SRM_Supplier)
        

        Delete SSM_ServiceProcess Where ShopCode <> @ShopCode
        Delete SSM_ServiceProcessStage Where ShopCode <> @ShopCode    

        Delete SYS_OperationLog Where ShopCode <> @ShopCode    
        
        Delete SYS_SyncPushToBase
        Delete SYS_SyncPushToShop
        
    COmmit
    SET XACT_ABORT off

该文章对您有用吗?

非常感谢,您的反馈对我们很有价值!

客服电话

4006757966

微信公众号

联系我们

印特3系演示版

申请

印特5系演示版

申请

免费试用

印特软件标准演示版下载申请

请您填写您的一些信息,提交您的申请后,我们会在两个工作日内进行处理,并回复您一封邮件,内附下载链接,请您注意查收。
*
请输入正确的公司名称
*
请输入正确的联络人员
*
请输入正确的联络电话
提交申请
关闭