• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4868
  • Last Modified:

sql (nolock)

I know i shoud use nolock on select queries in sql but shud i do it on views as well
thank you
0
yalamanchir
Asked:
yalamanchir
1 Solution
 
lauszCommented:
Is the same in views and selects because in the views you have a select query too.
0
 
eclipse2kCommented:
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
 
jdlambert1Commented:
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
 
ShogunWadeCommented:
"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
 
arbertCommented:
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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now