SqlServer教程

SQLSerServer简单触发器同步Bak表

本文主要是介绍SQLSerServer简单触发器同步Bak表,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
USE [ITL]
GO
/****** Object:  Trigger [dbo].[TR_LMS_Interface_Order_INSERT]    Script Date: 2022/8/23 17:16:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--然后存储过程

-- =============================================
-- Author:        ljz1
-- Create date: 2011-05-13 21:04
-- Description:    <Description,,>
-- =============================================
ALTER TRIGGER [dbo].[TR_LMS_Interface_Order_INSERT] ON [dbo].[LMS_Interface_Order]
    FOR INSERT
AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
        SET NOCOUNT ON;
        DECLARE @CustID AS CHAR(16);
        DECLARE @TypeID AS NVARCHAR(32);
        SELECT  @CustID = Inserted.CustID ,
                @TypeID = Inserted.TypeID
        FROM    Inserted;
     
        IF NOT ( CHARINDEX(RTRIM(@CustID), '1300009477,1300000681') > 0
                 AND RTRIM(@TypeID) = '000000033'
               )
            BEGIN
                INSERT  INTO [LMS_Interface_Order_bak]
                        ( RefID ,
                          Sign_Code ,
                          WareHouseProviderId ,
                          WareHouseCode ,
                          MidBusiID ,
                          PlanID_T ,
                          PlanID_F ,
                          StorkID_T ,
                          StorkID_F ,
                          CustomerID ,
                          CustID ,
                          OrderID ,
                          OrderCode ,
                          OrderType ,
                          TypeID ,
                          Operation_Type ,
                          Shipping ,
                          TradeID ,
                          CompanyCode ,
                          Presell ,
                          codflag ,
                          codItemValue ,
                          sendStartTime ,
                          sendEndTime ,
                          lmsItemNo ,
                          SpuCode ,
                          MaterialID ,
                          Qty ,
                          UnitPrice ,
                          MaterialSN ,
                          OperateRemark ,
                          Remark ,
                          LineCount ,
                          Item ,
                          OrderSendFlag ,
                          OutInflag ,
                          DelRemark ,
                          Marker1 ,
                          Marker2 ,
                          DelFlag ,
                          Creator ,
                          CreateTime ,
                          Modifier ,
                          ModifyTime ,
                          IPAddress ,
                          WarehouseID ,
                          ServiceCityID ,
                          ServiceName ,
                          PostCode ,
                          Phone ,
                          Mobile ,
                          [Address] ,
                          ItemName ,
                          ItemValue ,
                          SpuName ,
                          itemType ,
                          Prov ,
                          City ,
                          District ,
                          flag ,
                          [LOG] ,
                          Sign_Standard ,
                          VendeeCode ,
                          BatchCode ,
                          ERPFlag ,
                          InvoiceFlag ,
                          CarrierPay ,
                          DispatchDay ,
                          DispatchTime ,
                          DispatchNotify ,
                          DispatchCarrier ,
                          PrintRemark ,
                          BatchCode_To ,
                          Item_CustID ,
                          Item_CompID ,
                          Cust_StockID_F ,
                          Cust_PlanID_F ,
                          Cust_StockID_T ,
                          Cust_PlanID_T ,
                          Supplier ,
                        Buyer_ServiceName ,
                          Item_Remark ,
                          Insuranceflag ,
                          Insurancevalue ,
                          RouteID ,
                          DemandTime ,
                          IsCheckSN ,
                          Item_IsCheckSN ,
                          State_F ,
                          State_T ,
                          SpuCode_To ,
                          MaterialID_To ,
                          Item_SNFlag ,
                          CustID_T ,
                          SourceCode ,
                          ORDNO ,
                          Buyer_LevelInfo ,
                          Buyer_UserID ,
                          Sku_Size ,
                          PrevReference ,
                          ReTrafficnum ,
                          TrafficID ,
                          Customer_T ,
                          TransFlag ,
                          Shop_Nick ,
                          OrderTime ,
                          ShippingTime ,
                          Order_Flag ,
                          TMS_NO ,
                          cust_qty ,
                          GroupMaterFlag ,
                          Dealers ,
                          Town ,
                          SignInfo ,
                          Buyer_Email ,
                          GroupMaterialCode ,
                          GroupMaterialAreaID ,
                          packagepn ,
                          OrderLockFlag ,
                          ReOrderflag ,
                          Item_Remark1 ,
                          companyso ,
                          DOMemo ,
                          RefOrderCode ,
                          Marker3 ,
                          OrderWeight,
                          Item_Marker1,
                          Item_Marker2,
                          Item_Marker3,
                          Item_Remark2, --JHT-ADD
                          oaid,    --JHT-ADD
                          TDOFlag
                        )
                        SELECT  ID ,
                                Sign_Code ,
                                WareHouseProviderId ,
                                WareHouseCode ,
                                MidBusiID ,
                                PlanID_T ,
                                PlanID_F ,
                                StorkID_T ,
                                StorkID_F ,
                                CustomerID ,
                                CustID ,
                                OrderID ,
                                OrderCode ,
                                OrderType ,
                                TypeID ,
                                Operation_Type ,
                                Shipping ,
                                TradeID ,
                                CompanyCode ,
                                Presell ,
                                codflag ,
                                codItemValue ,
                                sendStartTime ,
                                sendEndTime ,
                                lmsItemNo ,
                                SpuCode ,
                                MaterialID ,
                                Qty ,
                                UnitPrice ,
                                MaterialSN ,
                                OperateRemark ,
                                Remark ,
                                LineCount ,
                                Item ,
                                OrderSendFlag ,
                                OutInflag ,
                                DelRemark ,
                                Marker1 ,
                                Marker2 ,
                                DelFlag ,
                                Creator ,
                                CreateTime ,
                                Modifier ,
                                ModifyTime ,
                                IPAddress ,
                                WarehouseID ,
                                ServiceCityID ,
                                ServiceName ,
                                PostCode ,
                                Phone ,
                                Mobile ,
                                [Address] ,
                                ItemName ,
                                ItemValue ,
                                SpuName ,
                                itemType ,
                                Prov ,
                                City ,
                                District ,
                                flag ,
                                [LOG] ,
                                Sign_Standard ,
                                VendeeCode ,
                                BatchCode ,
                                ERPFlag ,
                                InvoiceFlag ,
                                CarrierPay ,
                                DispatchDay ,
                                DispatchTime ,
                                DispatchNotify ,
                                DispatchCarrier ,
                                PrintRemark ,
                                BatchCode_To ,
                                Item_CustID ,
                                Item_CompID ,
                                Cust_StockID_F ,
                                Cust_PlanID_F ,
                                Cust_StockID_T ,
                                Cust_PlanID_T ,
                                Supplier ,
                                Buyer_ServiceName ,
                                Item_Remark ,
                                Insuranceflag ,
                                Insurancevalue ,
                                RouteID ,
                                DemandTime ,
                                IsCheckSN ,
                                Item_IsCheckSN ,
                                State_F ,
                                State_T ,
                                SpuCode_To ,
                                MaterialID_To ,
                                Item_SNFlag ,
                                CustID_T ,
                                SourceCode ,
                                ORDNO ,
                                Buyer_LevelInfo ,
                                Buyer_UserID ,
                                Sku_Size ,
                                PrevReference ,
                                ReTrafficnum ,
                                TrafficID ,
                                Customer_T ,
                                TransFlag ,
                                Shop_Nick ,
                                OrderTime ,
                                ShippingTime ,
                                Order_Flag ,
                                TMS_NO ,
                                Cust_Qty ,
                                GroupMaterFlag ,
                                Dealers ,
                                Town ,
                                SignInfo ,
                                Buyer_Email ,
                                GroupMaterialCode ,
                                GroupMaterialAreaID ,
                                packagepn ,
                                OrderLockFlag ,
                                ReOrderflag ,
                                Item_Remark1 ,
                                companyso ,
                                DOMemo ,
                                RefOrderCode ,
                                Marker3 ,
                                OrderWeight,
                                  Item_Marker1,
                          Item_Marker2,
                          Item_Marker3,
                          Item_Remark2, --JHT-ADD
                          oaid,TDOFlag
                        FROM    INSERTED;   

            END;
    END;

 

这篇关于SQLSerServer简单触发器同步Bak表的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!