Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
vipin7sep
Starting Member
1 Post |
Posted - 2009-08-26 : 06:33:40
|
| Create proc aas begin tran print @@trancount rollback tran print @@trancount if @@trancount > 0 begin Commit tran endgoCreate proc bas begin tran print @@trancount exec a print @@trancount if @@trancount > 0 begin Commit tran endgoExec b |
|
|
kunal.mehta
Yak Posting Veteran
83 Posts |
Posted - 2009-08-26 : 07:38:59
|
| Hi,some facts:1. There are no autonomous transactions in MS SQL Server like in Oracle. 2. We cannot rollback nested transaction. rollback statement rolls back outermost transaction.3. If rollback statement have a name, it rolls back to savepoint with such name or outermost transaction with such name.Now try thisalter proc aasdeclare @trana as varchar(10)SELECT @trana='Ta'declare @tranb as varchar(10)SELECT @tranb='Tb'SET IMPLICIT_TRANSACTIONS ONbegin tran @tranasave transaction @tranaprint @@trancountrollback tran @trana;print @@trancountif @@trancount > 0beginCommit tran @tranbendgoalter proc basdeclare @tranb varchar(10)SELECT @tranb='Tb'begin transaction @tranbprint @@trancountexec aprint @@trancountif @@trancount > 0beginCommit transaction @tranbendgoExec b |
 |
|
|
|
|
|