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
Post a Comment