Can you set SQL Query Analyzer to automatically use NOLOCK on Queries?

Posted on 2006-11-10
Last Modified: 2008-02-01

I'm a Crystal Reports expert. We've been instructed that when we use MS SQL Query Analyzer we must input the NOLOCK command with our queries. However that we do NOT need to worry about doing this with Crystal Report as they (DBA) tells me that Crystal Automatically does this.????(I'm checking with the Crystal Experts on this...)

I do not believe that Crystal Reports is using I can't see it in the SQL Query that is generated.

Anyway,...I'm just there a way to setup Query Analyzer to automatically consider my queries....AS .....NOLOCK.....??


Question by:MIKE
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 11

Expert Comment

ID: 17914141
As far as I know, this is not possible.
LVL 11

Assisted Solution

rw3admin earned 200 total points
ID: 17916747
No Crystal doesnt do that, Using NoLOCK is your SQL directive (hint) to Not use ANY existing locks on tables you cannot automatically set your queries to NOLOCK

I would advise highly against NOLOCK use, specially for reporting cause NOLOCK WILL read dirty records as it can read a table thats in transaction, may it be due to update insert or delete,
so imagine you are doing a mass update of price for items (increasing prices by 5%) and you use NOLOCKS and print this report they WILL see huge difference in TOTAL per their expectations, I can give you ten other examples like this.

NOLOCK should be used as monitoring any updates/deletes/inserts not for reporting...

LVL 17

Author Comment

ID: 17916928
We have separate servers for each process:  Development, Quality Assurance, Production.

Data on all of our servers are updated/refreshed every 15 mins.

Thanks for the added is much appreciated.

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

LVL 69

Accepted Solution

Scott Pletcher earned 300 total points
ID: 17917097
You can specify "READ UNCOMMITTED" as a *connection* setting and it will apply to *all* tables on *all* queries run thru that connection (it's equivalent to specifying "(NOLOCK)" on every table in every SELECT).
LVL 17

Author Comment

ID: 17917136
Ahhhhh awesome.... yes..this is what I'm thinking about...

LVL 17

Author Comment

ID: 17917142
Oh wait...but this would only be for users that would NEVER require...writing to database....correct?
LVL 69

Expert Comment

by:Scott Pletcher
ID: 17917203
It would apply per connection.  If the same connection were used for Crystal and, say, an app, the potential of "dirty reads" would apply to both.  Usually I've found that Crystal uses its own connection, typically via ODBC.

At any rate, it doesn't prevent writing, since writing will *always* lock.  You cannot turn off locking for inserts/updates/deletes; even if you specify it, SQL ignores it.

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
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…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

696 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