sql server 2012

Is adviciable to use nolock function in select query?

what is the diff of nolock and with (nolock)
kowsika deviAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
You should use NOLOCK only when it is unimportant whether the results are correct or not.

Cause NOLOCK can lead to return not (longer) existing data or to not return existing data. And there is no way for you to be sure..
Pawan KumarDatabase ExpertCommented:
Is adviciable to use nolock function in select query?
it depends.

It is equal to using READ UNCOMMITED as a transaction isolation level. So, you stand the risk of reading an uncommitted row that is subsequently rolled back, i.e. data that never made it into the database. So, while it can prevent reads being deadlocked by other operations, it comes with a risk. Basically you can get dirty reads. REF WITH(NOLOCK) - Does not improve performance. WITH(NOLOCK) is NOT by default.

Read more from -

With lock is by default and you do not have to specify anything for this.
kowsika deviAuthor Commented:
to avoid deadlock we can use otherwise it should not use is it correct jj
Get Blueprints for Increased Customer Retention

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

Pawan KumarDatabase ExpertCommented:
>>to avoid deadlock we can use otherwise it should not use is it correct jj
When you use NOLOCK  there is no guarantee that a deadlock will not occur. You need to optimize your query.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kowsika deviAuthor Commented:
thanks jj
Jim HornSQL Server Data DudeCommented:
Note to self:  Make one of those 'Worlds's Most Interesting Man' memes where the top says something like 'I don't always SELECT large sets in production databases', and the bottom says 'But when I do I use WITH(NOLOCK) and SET TRANSACTION LEVEL LOW'.
ste5anSenior DeveloperCommented:
Na, I only use NOLOCK to make queries faster.. ya 'now, no locking and that overhead transaction isolation voodoo.. :)

You won't believe how often I've seen NOLOCK used as "improved query performance"..
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.