SQL Interview: 55 Nested Transactions

SQL Interview: 55 Nested Transactions

This is a post in the SQL Interview series. These aren’t trick or gotcha questions, they’re just questions designed to scope out a candidate’s knowledge around SQL Server and Azure SQL Database.

Section: Administration Level: Medium

Question:

You have code that uses transactions.

There is an outer transaction that contains an inner transaction.

If the inner transaction code executes a ROLLBACK, what is rolled back? Is it the inner transaction, the outer transaction, or both?

Answer:

While the syntax for SQL Server transactions appears to support transaction nesting, if you roll back an inner transaction, it also rolls back any surrounding transaction, so both are rolled back.

2025-06-13