4
Reply

What is use of NoLock?

Rahul Chavan

Rahul Chavan

8y
529
0
Reply

    There is a situation where have possibility to more then one operation can have on same table or same time will occur in this case microsoft has been introduced Lock and WITH (NOLOCK). when read the record from tables.

    There is a situation where have possibility to more then one operation can have on same table or same time will occur in this case microsoft has been introduced Lock and WITH (NOLOCK). when read the record from tables.

    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 that never made it into the database. So, while it can prevent reads being deadlocked by other operations, it comes with a risk. In a banking application with high transaction rates, it's probably not going to be the right solution to whatever problem you're trying to solve with it IMHO.

    If you want to write a query to retrieve the data from table and do not lock the table/ records then we use Nolock.Example-SELECT * FROM Customer WITH (NOLOCK)