数据库
首页 > 数据库> > 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;

 

标签:触发器,Cust,--,PlanID,SQLSerServer,Item,Buyer,CustID,Bak
来源: https://www.cnblogs.com/yuanshuo/p/16617097.html