UnhandledExcepSean
UnhandledExcepSean

Reputation: 12804

Does NOLOCK still not require the WITH keyword?

We are migrating from SQL Server 2008 and moving to SQL Server 2014. I've searched the Microsoft documentation, but I could have sworn this

select * from table (nolock)

was going to be an invalid syntax and WITH was going to be required.

However, I can't seem to find it in the documentation and I tested it on a 2014 instance without issue.

Ignoring the whole "NOLOCKs is bad" thing, am I totally mis-remembering this or did this change in syntax get removed?

Upvotes: 2

Views: 538

Answers (1)

Heinzi
Heinzi

Reputation: 172260

You remember correctly. The SQL Server 2008 documentation says:

Omitting the WITH keyword is a deprecated feature: This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.

The current (SQL Server 2016) documentation still says the same thing.

So, yes, this is going to be invalid syntax, but Microsoft has not specified when exactly this will be the case.

Upvotes: 6

Related Questions