Solved

sql (nolock)

Posted on 2004-09-01
5
4,831 Views
Last Modified: 2012-06-27
I know i shoud use nolock on select queries in sql but shud i do it on views as well
thank you
0
Comment
Question by:yalamanchir
5 Comments
 
LVL 6

Expert Comment

by:lausz
ID: 11953444
Is the same in views and selects because in the views you have a select query too.
0
 
LVL 4

Accepted Solution

by:
eclipse2k earned 500 total points
ID: 11953482
Something i found about it.

"Whenever you create a view with NOLOCK hint, regardless to what isolation or transaction you run the tables data is fetched with the NOLOCK hint. You DONOT need to prefix the NOLOCK while using the View.
 
But when you use NOLOCK while using with the View directly and not having on individual tables, here the NOLOCK hint is applied to all the objects involved in the View. Hence there is an advantage. The application can decide to when to use the NOLOCK hint while querying. I support this mode of working only."

Maybe it helps.
0
 
LVL 15

Expert Comment

by:jdlambert1
ID: 11953516
I don't think you should use NOLOCK on SELECT statements, in views or otherwise. You can get dirty (uncommited/inconsistent) data that way. What are you trying to accomplish?
0
 
LVL 18

Expert Comment

by:ShogunWade
ID: 11953631
"I know i shoud use nolock on select queries ..."   - says who.     You should only use WITH(NOLOCK) if you understand that this is a dirty read and you know the issues and pittfalls.

I use WITH(NOLOCK) heavily on my current project but I know absolutely (due to the nature of the application) that when I issue such a statement my process will be the only process accessing the table and /or I desire dirty reads for monitoring purposes.
0
 
LVL 34

Expert Comment

by:arbert
ID: 11955293
Agree with ShogunWade--totally depends on your application.....We have several tables that we need to be able to update and we don't care if the users get dirty results--we just don't want them blocked by any of our processes--just all depends on whether or not you can afford users to have possibly incorrect information.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.

706 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

20 Experts available now in Live!

Get 1:1 Help Now