SA0225 : The usage of the NOLOCK and READUNCOMMITTED table hints is are deprecated in UPDATE, DELETE and MERGE statements

The topic describes the SA0225 analysis rule.

Message

The usage of the NOLOCK and READUNCOMMITTED table hints is are deprecated in UPDATE, DELETE and MERGE statements

Description

The rule checks for usage of NOLOCK and READUNCOMMITTED table hints in the FROM clause of UPDATE, DELETE or MERGE statements.

The NOLOCK and READUNCOMMITTED table hints are deprecated for usage on the target table in the FROM clause of UPDATE, DELETE and MERGE statements.

NOTE: The READUNCOMMITTED table hint produces syntax error when used with UPDATE, DELETE and MERGE statements. The NOLOCK hint produces syntax error with MERGE statement.

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

Deprecated Features, Bugs

Additional Information
Example Test Script
SQL
 1UPDATE Production.Product WITH (TABLOCK, NOLOCK)
 2SET ListPrice = ListPrice * 1.10
 3WHERE ProductNumber LIKE 'BK-%';
 4
 5DELETE FROM Production.Product WITH (NOLOCK) 
 6WHERE ListPrice > 1000;
 7
 8DELETE FROM Production.Product 
 9FROM Production.Product p  WITH (NOLOCK) 
10INNER JOIN 
11Sales.ProductSales p2 ON p.ProductId = p2.ProductId
12WHERE ListPrice > 1000;

Analysis Results

  Message Line Column
1 SA0225 : The NOLOCK is deprecated for use on the target table of UPDATE, DELETE and MERGE statements. 1 41
2 SA0225 : The NOLOCK is deprecated for use on the target table of UPDATE, DELETE and MERGE statements. 5 37
3 SA0225 : The NOLOCK is deprecated for use on the target table of UPDATE, DELETE and MERGE statements. 9 33
See Also

Other Resources