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
  • 相关阅读:
    Day 03
    Day 02
    Day 01
    re正则表达四
    python学习05之数据可视化
    python学习04之柱形图和热图
    python学习03之线图表
    python的学习02之数据处理
    python的学习01之csv文件处理
    中国大学排名实例
  • 原文地址:https://www.cnblogs.com/heimirror/p/1408113.html
Copyright © 2011-2022 走看看