zoukankan      html  css  js  c++  java
  • 用触发器替换原来的insert

    alter TRIGGER InsertEnterprise
       
    ON T_Enterprise
      instead 
    of INSERT 
    AS 
    BEGIN
        
    SET NOCOUNT ON;
        
    SET QUOTED_IDENTIFIER ON;
        
    declare @TempId int
        
    insert into fieldweb.dbo.enterpriseinfo(companyname,ServicesType,Location
        ,E_Code,EnterpriseNO)
        
    select companyname,industryid,address,postcode,enterprisecode from inserted
        
    select  @TempId=@@identity

        
    INSERT INTO [CRM].[dbo].[T_Enterprise]
               (
    [CompanyName]
               ,
    [EnterpriseCode]
               ,
    [WebSiteId]
               ,
    [IndustryId]
               ,
    [IndustryName]
               ,
    [NatrueId]
               ,
    [NatrueName]
               ,
    [Address]
               ,
    [PostCode]
               ,
    [WebUrl]
               ,
    [AddTime]
               ,
    [Operator])
               
    select
                
    [CompanyName]
               ,
    [EnterpriseCode]
               ,
    [WebSiteId]
               ,
    [IndustryId]
               ,
    [IndustryName]
               ,
    [NatrueId]
               ,
    [NatrueName]
               ,
    [Address]
               ,
    [PostCode]
               ,
    [WebUrl]
               ,
    [AddTime]
               ,
    [Operator]
                
    from inserted
        
    update t_enterprise set websiteid=@TempId where id=@@identity
        
    END
    GO
  • 相关阅读:
    Algorithm --> 最长回文子串
    Algorithm --> 筛法求素数
    c++ --> const关键字总结
    c++ --> 友元函数
    c++ --> static关键字总结
    c++ --> 父类与子类间的继承关系
    c++ --> 操作符重载
    Java设计模式应用——观察者模式
    Ignite集群管理——基于静态IP的节点发现
    线性回归的应用——容量预测
  • 原文地址:https://www.cnblogs.com/heimirror/p/1408113.html
Copyright © 2011-2022 走看看