Click or drag to resize

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, New Rules

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

Analysis Results

 MessageLineColumn
1SA0266 : ROLLBACK statement without corresponding BEGIN TRANSACTION statement.10
2SA0266 : ROLLBACK statement without corresponding BEGIN TRANSACTION statement.90
3SA0266 : ROLLBACK statement without corresponding BEGIN TRANSACTION statement.140
See Also

Other Resources