Update Query with Nolock hint

Ram Mehta picture Ram Mehta · Feb 18, 2014 · Viewed 36.6k times · Source

I am trying to put an with(NOLOCK) on an update query:

UPDATE pth_patchLookup with(nolock) SET ScanDateTime = Getdate() WHERE RegID = 312

but I get the following message :

NoLock hint is supported only with Select statement and not with update, insert and delete.

Is there any manner in which I can apply a 'NOLOCK" on this update query ?

Thanks for any help

Answer

Amir Keshavarz picture Amir Keshavarz · Feb 18, 2014

(NOLOCK) disables shared locks and not exclusive locks. you can use Read Committed isolation level in order to place an exclusive lock on select statements.

SET TRANSACTION ISOLATION LEVEL READ COMMITTED 
UPDATE pth_patchLookup SET ScanDateTime = Getdate() WHERE RegID = 312