SQL WITH (NO LOCK) Statements

Hello Friends,


Sometimes we try to run big query to fetch records from our database and it takes long time to execute. To avoid this kind of issue we should use SQL LOCK. First of all we should to know how it works if two processes are trying to access the same data at the same time, query runs slower reason one process will have to wait while other finished. That’s why NO LOCK comes into the picture. If you fetching more records from the database at that time you can use NO LOCK to make your query run faster. 
You need to add WITH (NO LOCK) in your FROM clause. Here are the syntax
SELECT empId, empName, salary, telphone FROM EmployeeMaster WITH (NOLOCK)

Comments