CREATE  TRIGGER xxx_insert ON dbo.tablename FOR INSERT NOT FOR REPLICATION
AS
DECLARE @id1      INT
DECLARE @id3      INT
SELECT @id1= id1, @id3= id3 from inserted
insert into table2 values(@id1,@id3)

解决方案 »

  1.   

    create trigger tr1 on table1
    for insert
    as 
    begin
    insert table2(id1,id3) select id1,id3 from instered
    end
      

  2.   

    create trigger tr1 on table1
    for insert
    as 
    begin
    insert into table2 select id1,id3 from instered
    end
      

  3.   

    create trigger tr1 on table1
    for insert
    as 
    if exists(select id1 ,id3 from inserted  i join tabgle1 t on i.id1=t.id1 and i.id3=t.id3)
    begin
    insert into table2 select id1,id3 from instered
    end