Using with nolock in SQL Queries

Hello everyone,

I will talk about NOLOCK keywork in T-Sql.

NOLOCK prevents locking of tables in SQL Server. In ordinary create/update/delete operations the table is locked until we get response from the sql query. For example; If you update a table without using nolock keyword you cannot query that table meanwhile(deadlock).

In small or medium-sized project this situation may be negligible, but in big projects this can be a big trouble.

You can use nolock like below(just use WITH (NOLOCK) at the end of your table name):

select * from Contact WITH (NOLOCK)

The usage of NOLOCK is very critical. If instant results are highly important for your query then you should’nt use NOLOCK (i.e: in banking applications).

 

Hope that helps!

Leave a Reply

Your email address will not be published. Required fields are marked *