应该是可以的。
create table ta(a int)
create table tb(b int)
--触发器:
create trigger tri on ta for insert
as
insert tb select * from inserted
go
--事务性的插入:
create proc p
as
begin tran
insert ta
select 1 union all select 2 union all select 3 union all select 4
if @@error=0
commit tran
else
rollback
go
--测试:
exec p
go
select * from ta
select * from tb
/*
a
-----------
1
2
3
4(4 row(s) affected)b
-----------
4
3
2
1(4 row(s) affected)
*/
drop trigger tri
drop proc p
drop table ta
drop table tb

解决方案 »

  1.   


    exec p
    go
    --执行它时,有下面的提示,可见触发器是正常工作的。
    /*(4 row(s) affected)(4 row(s) affected)*/
      

  2.   

    for szx1999.你这样插入的数据.是固定了的数据吧?我现在就是要把程序里面插入至在建立触发器的那个表里面的数据.触发插入至另一个表.在inserted里面.每触发一次.只有一条数据.你可以建立一个时间字段.加毫秒的.你在程序的里建立的事务里插很多条数据的话.触发过来的时间字段是不同的.这个我测试过了.用FOR.和AFTER触发器都是一样的.不知道还没有其他的设置.