Sql Server nested transaction rollback @@TRANCOUNT -


i've got stored procedure begins new transaction data manipulation. procedure executed within transaction.
have no influence happens before procedure. , change.

my idea check @@trancount before begin nested transaction. check @@trancount again in catch block , compare it. in no case want outer transaction rollbacked. wonder if safe code?

thx help!

set @transcountbefore = @@trancount;  begin transaction tx; begin try   /* data manipulation here */   commit transaction tx;        end try             begin catch   if @@trancount > @transcountbefore rollback transaction tx;   /* error handling here */    end catch; 


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -