SOLVED

Table Hint Position in From Clause

Copper Contributor

The documentation (https://learn.microsoft.com/en-us/sql/t-sql/queries/from-transact-sql?view=sql-server-ver16) for the FROM clause syntax shows the table hints after the table alias. I have recently come across a few queries in which the developer put a nolock hint between the table name and the alias, e.g., FROM dbo.Customer (nolock) cst. No error is thrown. I do not have access to view query plans.

 

Do table hints placed between the table name and alias do anything?

 

Thank you.

2 Replies
best response confirmed by Mister_Gregory (Copper Contributor)
Solution

 


No error is thrown.

@Mister_Gregory that's old syntax from Sybase time; that syntax is deprecated and one should avoid them.

Also you should always use the WITH keyword in combination with table/query hints, see

SQL Server, Deprecated Features object - SQL Server | Microsoft Learn

=> Table hint without WITH

@olafhelper - Thank you very much!

1 best response

Accepted Solutions
best response confirmed by Mister_Gregory (Copper Contributor)
Solution

 


No error is thrown.

@Mister_Gregory that's old syntax from Sybase time; that syntax is deprecated and one should avoid them.

Also you should always use the WITH keyword in combination with table/query hints, see

SQL Server, Deprecated Features object - SQL Server | Microsoft Learn

=> Table hint without WITH

View solution in original post