NOLOCK
NOLOCK does not lock any object.
This is the default for
SELECT
operations.
It does not apply to
INSERT
,
UPDATE
, and
DELETE
statements.
Examples:
SELECT OrderID
FROM Orders WITH (ROWLOCK)
WHERE OrderID BETWEEN 100
AND 2000
UPDATE Products WITH (NOLOCK)
SET ProductCat = 'Machine'
WHERE ProductSubCat = 'Mac'
Ref: SQLAuthority.com
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 never made it into the database. So, while it can prevent reads being deadlocked by other operations, it comes with a risk.
Please refer:
Using NOLOCK[
^]
Using MS-SQL's NOLOCK for faster queries[
^]
Note: Don't use NOLOCK to do any writing of data, or even for quick reads.
You can get more details on links provided above.
Hope it helps!