Click or drag to resize

SA0108 : Avoid using NOLOCK hint, use isolation levels instead

The topic describes the SA0108 analysis rule.

Message

Avoid using NOLOCK hint, use isolation levels instead

Description

The rule checks for NOLOCK hints are found within SQL code.

Consider changing the isolation level instead of using the NOLOCK hint.

Scope

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

Parameters
NameDescriptionDefault Value
RuleSuppressMark

Suppress rule reporting a rule violation in case a comment containing the value of this parameter is found close to the source of violation.

IGNORE:SA0108

Remarks

The rule does not need Analysis Context or SQL Connection.

Categories

Design Rules

Additional Information

There is no additional info for this rule.

Example Test Script
SQL
1--- Table Hints ---
2SELECT StartDate, ComponentID FROM Production.BillOfMaterials
3    WITH( INDEX (FIBillOfMaterialsWithComponentID), NOLOCK /*IGNORE:SA0108*/ )
4    WHERE ComponentID in (533, 324, 753, 855, 924);
5
6SELECT * FROM Sales.SalesOrderHeader (NOLOCK) AS h 
7
8SELECT * FROM Sales.SalesOrderHeader AS h (NOLOCK)

Analysis Results

 MessageLineColumn
1SA0108 : Avoid using NOLOCK hint, use isolation levels instead.638
2SA0108 : Avoid using NOLOCK hint, use isolation levels instead.843
See Also

Other Resources