create proc
...
as
begin
set xact_abort on --设置出错时自动回滚事务
begin transaction
insert tabel1 vaule(...)
if @@error<>0 then
begin
rollback transaction
return
end
insert tabel2 vaule(...)
if @@error<>0 then
begin
rollback transaction
return
end
commit transaction
return
...
as
begin
set xact_abort on --设置出错时自动回滚事务
begin transaction
insert tabel1 vaule(...)
if @@error<>0 then
begin
rollback transaction
return
end
insert tabel2 vaule(...)
if @@error<>0 then
begin
rollback transaction
return
end
commit transaction
return