Click or drag to resize

SA0021 : Deprecated usage of table hints without WITH keyword

The topic describes the SA0021 analysis rule.

Message

Deprecated usage of table hints without WITH keyword

Description

This rule checks stored for use of table hints without the WITH keyword.

It is recommended that hints be specified using the WITH keyword. SQL Server 2005 does not support the use of more than one hints in a T-SQL statement unless the WITH keyword is specified.

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

Additional Information

There is no additional info for this rule.

Example Test Script
 1SELECT  au_id
 2FROM  dbo.authors( UPDLOCK, PAGLOCK) -- Usage of the WITH keyword is recommended  
 3
 4SELECT  au_id
 5FROM  dbo.authors  WITH( UPDLOCK, PAGLOCK)
 6
 7SELECT  nolock.*
 8FROM  sys.objects as nolock
 9
10SELECT  *
11FROM  sys.objects nol
12
13SELECT  *
14FROM  sys.objects nolock

Analysis Results

 MessageLineColumn
1SA0021 : Deprecated usage of table hints without WITH keyword.219
2SA0021 : Deprecated usage of table hints without WITH keyword.228
3SA0021 : Table hint is not enclosed in parentheses and will be considered as a table alias.1418
See Also

Other Resources