WITH (NOLOCK) in SQL Server

Akiii
Posted by Akiii under Sql Server category on | Points: 40 | Views : 1385
select * from customer with (nolock);


 select * from customer;



Both the above statements will give you the same results. But, there is a catch. Suppose customer table is being updated and then you execute the first query containing nolock then it might result in DIRTY READ.

WITH (NOLOCK) - It only applies to the SELECT statement. it does'nt consider the transaction scenario, even if the transaction is under process or not yet committed or rollback, it will fetch the current record no matter what. Use this feature when the performance needs to be increased.



Thanks and Regards
Akiii

Comments or Responses

Login to post response