begn transaction
declare @errorsum int
set @errorsum=0
执行语句
set @errorsum=@errorsum+@@error
if(@errorsum<>0)
begin
rollback transaction
end
else
commit transaction