SA0241 : Check transaction and savepoint names for following specified naming convention

The topic describes the SA0241 analysis rule.

Message

Check transaction and savepoint names for following specified naming convention

Description

The rule checks T-SQL code for transaction and savepoint names and reports names, which do not match the configured name patterns.

Check the rule parameters for configuring the available name pattern parameters.

Scope

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

Parameters
Name Description Default Value
TransactionNamePattern

Transaction name pattern.

regexp:[A-Z][A-Za-z_]+

SavepointNamePattern

Savepoint name pattern.

regexp:[A-Z][A-Za-z_]+

DistributedTransactionNamePattern

Distributed transaction name pattern.

regexp:[A-Z][A-Za-z_]+

Remarks

The rule does not need Analysis Context or SQL Connection.

Categories

Naming Rules, Code Smells

Additional Information

There is no additional info for this rule.

Example Test Script
SQL
 1BEGIN DISTRIBUTED TRAN  TRAN1
 2COMMIT TRAN TRAN1
 3
 4BEGIN TRANSACTION TRAN_1
 5SAVE TRANSACTION TRAN_1_SAVEPOINT
 6ROLLBACK TRAN TRAN_1
 7
 8DECLARE @TranName VARCHAR(20);  
 9SELECT @TranName = 'TRAN_3a';  
10SET @TranName = 'TRAN_3b';  
11BEGIN TRANSACTION @TranName;  
12COMMIT TRANSACTION @TranName;

Analysis Results

  Message Line Column
1 SA0241 : The distributed transaction name [TRAN1] does not match the naming convention. The expected key name is [[A-Z][A-Za-z_]+]. 1 24
2 SA0241 : The transaction name [TRAN_1] does not match the naming convention. The expected key name is [[A-Z][A-Za-z_]+]. 4 18
3 SA0241 : The savepoint name [TRAN_1_SAVEPOINT] does not match the naming convention. The expected key name is [[A-Z][A-Za-z_]+]. 5 17
4 SA0241 : The transaction name [TRAN_3b] does not match the naming convention. The expected key name is [[A-Z][A-Za-z_]+]. 11 18
See Also

Other Resources