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

Rule has no parameters.

Remarks

The rule does not need Analysis Context or SQL Connection.

Categories

Design Rules, Bugs

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

  Message Line Column
1 SA0108 : Avoid using NOLOCK hint, use isolation levels instead. 6 38
2 SA0108 : Avoid using NOLOCK hint, use isolation levels instead. 8 43
See Also

Other Resources