SA0266 : ROLLBACK statement without corresponding BEGIN TRANSACTION statement |
![]() |
The topic describes the SA0266 analysis rule.

ROLLBACK statement without corresponding BEGIN TRANSACTION statement

The rule checks T-SQL code and reports ROLLBACK statements, which have no corresponding BEGIN TRANSACTION statements.
Issuing a ROLLBACK TRANSACTION when @@TRANCOUNT is zero results in an error.

Review transaction statements and code paths to make sure that the ROLLBACK statement has a corresponding BEGIN TRANSACTION statement.

The rule has a Batch scope and is applied only on the SQL script.

Rule has no parameters.

The rule does not need Analysis Context or SQL Connection.


Design Rules, Bugs


SQL
1ROLLBACK 2 3BEGIN TRANSACTION 4 5ROLLBACK 6 7COMMIT 8 9ROLLBACK 10 11BEGIN TRANSACTION 12ROLLBACK 13 14ROLLBACK |

Message | Line | Column | |
---|---|---|---|
1 | SA0266 : ROLLBACK statement without corresponding BEGIN TRANSACTION statement. | 1 | 0 |
2 | SA0266 : ROLLBACK statement without corresponding BEGIN TRANSACTION statement. | 9 | 0 |
3 | SA0266 : ROLLBACK statement without corresponding BEGIN TRANSACTION statement. | 14 | 0 |
