SA0266 : ROLLBACK statement without corresponding BEGIN TRANSACTION statement

The topic describes the SA0266 analysis rule.

Message

ROLLBACK statement without corresponding BEGIN TRANSACTION statement

Description

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.

Scope

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

Parameters

Rule has no parameters.

Remarks

The rule does not need Analysis Context or SQL Connection.

Categories

Design Rules, Bugs

Additional Information
Example Test Script
SQL
 1ROLLBACK
 2
 3BEGIN TRANSACTION
 4
 5ROLLBACK
 6
 7COMMIT 
 8
 9ROLLBACK
10
11BEGIN TRANSACTION
12ROLLBACK
13
14ROLLBACK

Analysis Results

  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
See Also

Other Resources