I am trying to write an MS sql script that has a transaction and a try/catch block. If it catches an exception, the transaction is rolled back. If not, the transaction is
Transaction counter
--@@TRANCOUNT = 0 begin try --@@TRANCOUNT = 0 BEGIN TRANSACTION tran1 --@@TRANCOUNT = 1 --your code -- if failed @@TRANCOUNT = 1 -- if success @@TRANCOUNT = 0 COMMIT TRANSACTION tran1 end try begin catch print 'FAILED' end catch