About SQL Server with (NOLOCK) and (NOLOCK)

Source: Internet
Author: User
Tags deprecated sql server books

The difference is, you should are using the syntax WITH (NOLOCK) (or WITH (<any table hint>) ). Why?

    1. 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.

    2. 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.

    3. from table1 as mytable nolockis 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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.