Solved

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

Posted on 2006-11-10
7
958 Views
Last Modified: 2008-02-01
Experts:

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 NOLOCK....as I can't see it in the SQL Query that is generated.

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


Thanks


MikeV
0
Comment
Question by:MIKE
7 Comments
 
LVL 11

Expert Comment

by:Otana
Comment Utility
As far as I know, this is not possible.
0
 
LVL 11

Assisted Solution

by:rw3admin
rw3admin earned 200 total points
Comment Utility
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...

0
 
LVL 17

Author Comment

by:MIKE
Comment Utility
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 insight....it is much appreciated.

MikeV
0
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 
LVL 69

Accepted Solution

by:
ScottPletcher earned 300 total points
Comment Utility
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).
0
 
LVL 17

Author Comment

by:MIKE
Comment Utility
Ahhhhh awesome.... yes..this is what I'm thinking about...


Thanks
MikeV
0
 
LVL 17

Author Comment

by:MIKE
Comment Utility
Oh wait...but this would only be for users that would NEVER require...writing to database....correct?
0
 
LVL 69

Expert Comment

by:ScottPletcher
Comment Utility
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.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

743 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

13 Experts available now in Live!

Get 1:1 Help Now