应该是可以的。
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
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
exec p
go
--执行它时,有下面的提示,可见触发器是正常工作的。
/*(4 row(s) affected)(4 row(s) affected)*/