views:

498

answers:

2

Does sql server allow nested transactions? If so then whats the priority of transactions?

+6  A: 

From the MSDN documentation on SQL Server. Nesting Transactions:

Committing inner transactions is ignored by the SQL Server Database Engine. The transaction is either committed or rolled back based on the action taken at the end of the outermost transaction. If the outer transaction is committed, the inner nested transactions are also committed. If the outer transaction is rolled back, then all inner transactions are also rolled back, regardless of whether or not the inner transactions were individually committed.

ichiban
thanks i tested it and works exactly same as you told
Bhaskar
+3  A: 

Just to qualify this and directly answer the question, yes SQL Server does allow the nesting of transactions.

The quoted reference kindly provided by ichiban, details that the outcome of outermost transaction will determine whether or not nested transactions are committed.

John Sansom