Solved

with (nolock)

Posted on 2006-11-29
2
558 Views
Last Modified: 2006-11-29
Hi,

I am using SQL-2005

But If I use with (nolock)

in the query it gives me error:

Msg 319, Level 15, State 1, Line 12
Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.


But, I want to add with (nolock) in my query


SELECT TOP 10 CUSDETAIL.DCOP_CULTURE ,CUSDETAIL.DCOP_ID, CUSDETAIL.CTCT_ID, CUSDETAIL.CTCT_CREATIONDATE, CUSDETAIL.CTCT_LASTACCESSDATE,
                                            CUSDETAIL.CTCT_TITLE, CUSDETAIL.CTCT_FIRSTNAME,
                                    CUSDETAIL.CTCT_LASTNAME, CUSDETAIL.CTCT_DECRYPT_PASSWORD,
                                            CUSDETAIL.CTCT_ADDRESSLINE1, CUSDETAIL.CTCT_ADDRESSLINE2, CUSDETAIL.CTCT_ADDRESSLINE3,
                                            CUSDETAIL.CTCT_BUILDINGNUMBER, CUSDETAIL.CTCT_CITY, CUSDETAIL.CTCT_POSTCODE, CUSDETAIL.CTCT_STATE_COUNTY,
                                            CUSDETAIL.COCU_ID, CUSDETAIL.CTCT_EMAIL, CUSDETAIL.CTCT_NATIONALITY, CUSDETAIL.CTPL_ID,CUSDETAIL.DCOP_MARKETINGCONTACTEMAIL,
                                            CUSDETAIL.DCOP_MARKETINGCONTACTEPOSTAL, CUSDETAIL.DCOP_MARKETINGCONTACTETHIRDPARTY,
                                            CUSDETAIL.COCU_CODE, CUSDETAIL.CTPL_CODE, CUSDETAIL.DCOP_MIGRATE_STATUS
                                     FROM B025765.ENET_20NOV_NEW.DBO.VW_CUSTOMER_PERSONAL_DETAIL  CUSDETAIL
                                                            LEFT OUTER JOIN B025765.VB_MIGRATED_CUSTOMER.DBO.MIGRATED_CUSTOMER MIG_CUS
                                                                  ON CUSDETAIL.CTCT_ID <> MIG_CUS.CTCT_ID AND CUSDETAIL.CTCT_EMAIL <> MIG_CUS.CTCT_EMAIL
                                                            with (nolock)
                                    WHERE CUSDETAIL.DCOP_CULTURE ='en-US'
                                     AND CUSDETAIL.DCOP_MIGRATE_STATUS IS NULL
                                     AND CUSDETAIL.CTCT_DECRYPT_PASSWORD <> '!!!!' AND CUSDETAIL.CTCT_DECRYPT_PASSWORD IS NOT  NULL
                                     

                                                      

Thanks
0
Comment
Question by:dinesh_bali
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
(NOLOCK) comes either behind the tablename (without "WITH"), or at the very end of the query:

SELECT TOP 10 CUSDETAIL.DCOP_CULTURE ,CUSDETAIL.DCOP_ID, CUSDETAIL.CTCT_ID, CUSDETAIL.CTCT_CREATIONDATE, CUSDETAIL.CTCT_LASTACCESSDATE,
                                            CUSDETAIL.CTCT_TITLE, CUSDETAIL.CTCT_FIRSTNAME,
                              CUSDETAIL.CTCT_LASTNAME, CUSDETAIL.CTCT_DECRYPT_PASSWORD,
                                            CUSDETAIL.CTCT_ADDRESSLINE1, CUSDETAIL.CTCT_ADDRESSLINE2, CUSDETAIL.CTCT_ADDRESSLINE3,
                                            CUSDETAIL.CTCT_BUILDINGNUMBER, CUSDETAIL.CTCT_CITY, CUSDETAIL.CTCT_POSTCODE, CUSDETAIL.CTCT_STATE_COUNTY,
                                            CUSDETAIL.COCU_ID, CUSDETAIL.CTCT_EMAIL, CUSDETAIL.CTCT_NATIONALITY, CUSDETAIL.CTPL_ID,CUSDETAIL.DCOP_MARKETINGCONTACTEMAIL,
                                            CUSDETAIL.DCOP_MARKETINGCONTACTEPOSTAL, CUSDETAIL.DCOP_MARKETINGCONTACTETHIRDPARTY,
                                            CUSDETAIL.COCU_CODE, CUSDETAIL.CTPL_CODE, CUSDETAIL.DCOP_MIGRATE_STATUS
                                     FROM B025765.ENET_20NOV_NEW.DBO.VW_CUSTOMER_PERSONAL_DETAIL  CUSDETAIL
                                                  LEFT OUTER JOIN B025765.VB_MIGRATED_CUSTOMER.DBO.MIGRATED_CUSTOMER MIG_CUS
                                                       ON CUSDETAIL.CTCT_ID <> MIG_CUS.CTCT_ID AND CUSDETAIL.CTCT_EMAIL <> MIG_CUS.CTCT_EMAIL
                                    WHERE CUSDETAIL.DCOP_CULTURE ='en-US'
                                     AND CUSDETAIL.DCOP_MIGRATE_STATUS IS NULL
                                     AND CUSDETAIL.CTCT_DECRYPT_PASSWORD <> '!!!!' AND CUSDETAIL.CTCT_DECRYPT_PASSWORD IS NOT  NULL
with (nolock)


or


SELECT TOP 10 CUSDETAIL.DCOP_CULTURE ,CUSDETAIL.DCOP_ID, CUSDETAIL.CTCT_ID, CUSDETAIL.CTCT_CREATIONDATE, CUSDETAIL.CTCT_LASTACCESSDATE,
                                            CUSDETAIL.CTCT_TITLE, CUSDETAIL.CTCT_FIRSTNAME,
                              CUSDETAIL.CTCT_LASTNAME, CUSDETAIL.CTCT_DECRYPT_PASSWORD,
                                            CUSDETAIL.CTCT_ADDRESSLINE1, CUSDETAIL.CTCT_ADDRESSLINE2, CUSDETAIL.CTCT_ADDRESSLINE3,
                                            CUSDETAIL.CTCT_BUILDINGNUMBER, CUSDETAIL.CTCT_CITY, CUSDETAIL.CTCT_POSTCODE, CUSDETAIL.CTCT_STATE_COUNTY,
                                            CUSDETAIL.COCU_ID, CUSDETAIL.CTCT_EMAIL, CUSDETAIL.CTCT_NATIONALITY, CUSDETAIL.CTPL_ID,CUSDETAIL.DCOP_MARKETINGCONTACTEMAIL,
                                            CUSDETAIL.DCOP_MARKETINGCONTACTEPOSTAL, CUSDETAIL.DCOP_MARKETINGCONTACTETHIRDPARTY,
                                            CUSDETAIL.COCU_CODE, CUSDETAIL.CTPL_CODE, CUSDETAIL.DCOP_MIGRATE_STATUS
                                     FROM B025765.ENET_20NOV_NEW.DBO.VW_CUSTOMER_PERSONAL_DETAIL (nolock)  CUSDETAIL
                                                  LEFT OUTER JOIN B025765.VB_MIGRATED_CUSTOMER.DBO.MIGRATED_CUSTOMER (nolock) MIG_CUS
                                                       ON CUSDETAIL.CTCT_ID <> MIG_CUS.CTCT_ID AND CUSDETAIL.CTCT_EMAIL <> MIG_CUS.CTCT_EMAIL
                                    WHERE CUSDETAIL.DCOP_CULTURE ='en-US'
                                     AND CUSDETAIL.DCOP_MIGRATE_STATUS IS NULL
                                     AND CUSDETAIL.CTCT_DECRYPT_PASSWORD <> '!!!!' AND CUSDETAIL.CTCT_DECRYPT_PASSWORD IS NOT  NULL


0
 

Author Comment

by:dinesh_bali
Comment Utility
Many Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now