Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
What is the meaning of the (Nolock) in sql server and pls explain with an example ?
Posted

You have given many good links already, but I would suggest also going through this article What should be considered when NOLOCK hint is used[^]
 
Share this answer
 
Comments
Espen Harlinn 19-Aug-12 8:29am    
Nice link :-D
Wendelius 19-Aug-12 8:31am    
Thanks, couldn't resist :)
WITH (NOLOCK) is the equivalent of 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 never made it into the database. So, while it can prevent reads being deadlocked by other operations.

SQL
SELECT * FROM Employee WITH (READUNCOMMITTED)


this is same as
SQL
SELECT * FROM Employee  WITH NOLOCK


The NOLOCK and READUNCOMMITED hints are only allowed with SELECT statements. If we try to use this for an UPDATE, DELETE or INSERT we will get an error.

Check this link for an example.

http://www.mssqltips.com/sqlservertip/2470/understanding-the-sql-server-nolock-hint/[^]
 
Share this answer
 
v2
Comments
RaviRanjanKr 18-Aug-12 1:33am    
Always wrap your Code in "pre" tag.
Espen Harlinn 19-Aug-12 8:30am    
Nice reply :-D
When you use the NOLOCK query hint you are telling the storage engine that you want to access the data no matter if the data is locked by another process or not.
Reference Link :- What does WITH (NOLOCK) actually mean[^]
 
Share this answer
 
Comments
Espen Harlinn 19-Aug-12 8:30am    
5'ed!
RaviRanjanKr 20-Aug-12 1:05am    
Thanks :)
 
Share this answer
 
Kindly refer the below link:

Use of (NOLOCK) in SQL[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900