在触发器里回滚触发器里的SQL,且不影响原有的操作

if object_id('tb') is not null
drop table tb
go
create table tb(id int,name varchar(50) not null)
go

create proc proc_t5
as
begin
select 1/0
end
go
create trigger tri_tb
on tb
for insert
as
begin
set xact_abort off
if update(name)
begin
save tran t1
exec proc_t5
if @@error <>0
rollback tran t1
else
commit tran t1
end
end
go
insert into tb select 1,'a'

select * from tb
--tb有1 a

http://topic.csdn.net/u/20090424/13/752942f9-16bb-45c4-b6a0-e8b635dabad3.html?seed=1387350230

你可能感兴趣的:(html,sql,.net,Go)