SA0138 : BEGIN TRANSACTION statement without ROLLBACK statement

The topic describes the SA0138 analysis rule.

Message

BEGIN TRANSACTION statement without ROLLBACK statement

Description

The rule checks T-SQL code for BEGIN TRANSACTION statement, which is not followed by a ROLLBACK statement.

While ROLLBACK statement is not required, it is necessary for good error handling practices.

How to fix

Review the code and consider adding ROLLBACK to the code branches where the transaction changes should be rolled back.

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.

Effort To Fix
20 minutes per issue.
Categories

Design Rules

Additional Information
Example Test SQL
SQL
1BEGIN TRANSACTION
2
3ROLLBACK
4
5BEGIN TRANSACTION

Analysis Results
  Message Line Column
1 SA0138 : BEGIN TRANSACTION statement without ROLLBACK statement. 5 0
See Also

Other Resources