SET IMPLICIT_TRANSACTIONS OFFGO... here comes the original script ...
declare @i int, @j intset @i = 1create table #temp (id int)while (@i<=5)begin -- while loop begin try -- trap errors begin transaction if (@i = 3) set @j = @i/0 insert into #temp values (@i) -- insert values when there are no errors print '@i = [' + Convert(varChar(8), @i) + ']' commit transaction end try begin catch -- handle errors rollback transaction print 'An error was caught when @i = [' + Convert(varChar(8), @i) + ']'; end catch set @i = @i + 1 end -- while loopselect * from #tempdrop table #temp