create trigger testtrig on tablename1 for insert
as
  insert tablename2 select col1, col2 from inserted

解决方案 »

  1.   

    create trigger dddd
    on tablename
    for insert
    as 
    begin
      insert tablenameother select col,... from inserted
    end
      

  2.   

    不行呀
    create trigger test on user1 for insert
    AS
    BEGIN
        insert into user2(userName) select uid from inserted
    end
    现在我往user1里面插入一条数据,结果还是没有被插入到uesr2表中
      

  3.   

    你不要管那个“(所影响的行数为 1 行)”,看数据进去没有,下面的代码测试通过,数据添加进去了
    -------------------------
    if object_id('table1') is not null drop table table1
    go
    select 1 as col1, 'a' as col2, 'a' as col3 into table1if object_id('table2') is not null drop table table2
    go
    select 1 as col1, 'a' as col2 into table2
    go
    if object_id('test') is not null drop trigger test
    go
    create trigger test on table1 for insert
    as
      insert into table2 select col1, col2 from inserted
    go
    insert into table1 values(2, 'b', 'b')
    go
    select * from table1
    /*
    col1   col2    col3
    2 b b
    1 a a
    */
    select * from table2
    /*
    col1   col2
    2 b
    1 a
    */drop trigger test
    drop table table1
    drop table table2
      

  4.   

    恩,可以了,那如果是update触发器呢???
      

  5.   

    update 就是把for insert改成for update,其他不变