Monday, March 19, 2012

Aid with store procedure

Hello, I have a problem, I want to execute in a single transaction three insert in store procedure, as it could implement. Thanks for its attentione.g.

create proc usp
as
begin tran
insert tb1 values(...)
if @.@.error<>0 goto rollbk
insert tb2 values(...)
if @.@.error<>0 goto rollbk
insert tb3 values(...)
if @.@.error=0
begin
commit
goto done
end

rollbk:
rollback

done:
return

GO

No comments:

Post a Comment