Auto Ads code

Showing posts with label TRANSACTION. Show all posts
Showing posts with label TRANSACTION. Show all posts

Saturday, June 22, 2019

What is use of NOLOCK ?

Use of NOLOCK


  • NOLOCK is also known and dirty reading or blind reading in SQL Server.
  • User can read uncommitted data without any wait by using NOLOCK.
  • NOLOCK ignore the any LOCK given to transaction by any SQL user.
Example : 


Code :


BEGIN TRANSACTION 
UPDATE C 
SET C.ContactName='' 
FROM Customers C 
WHERE C.CustomerId = 2
-------------------------------------------------

select * from Customers WHERE CustomerId = 2

-----------------------------------------------

select * from Customers WITH (NOLOCK) WHERE CustomerId = 2