The difference is, you should are using the syntax WITH (NOLOCK)
(or WITH (<any table hint>)
). Why?
Without is WITH
deprecated. From Table Hints on MSDN:
Omitting the WITH keyword is a deprecated feature:this feature would be removed in a future version of Microsoft SQL Serve R. Avoid using this feature in the new development work, and plan to modify applications the currently use this feature.
-
from table1 nolock
does Not apply a hint at All-that's an alias. For example:
SELECT Nolock.name from sys.objects nolock ORDER by nolock.name;
notice that I can use nolock
as an alias. No hint is applied here.
from table1 as mytable nolock
is invalid syntax in modern versions of SQL Server.
MSG 1018, Level A, State 1, line 12
Incorrect syntax near ' nolock '. If the is intended as a part of a table hint, a with keyword and parenthesis be now required. See SQL Server Books Online for proper syntax.
About SQL Server with (NOLOCK) and (NOLOCK)