Can you give some examples of (Lock Hints) in SQL Server

Can you give some examples of (Lock Hints) in SQL Server

gokuls3000
Views: 614 | Community Opinion: 1



Bookmark this page..



Ask a New Question Go to Home

Community Opinion/Answers
 
Swaran S. Kalair Said..

Locking hints enable to make minute adjustments in the locking strategy. While the isolation level affects the entire connection, locking hints are specific to one table within one query. The "with (locking hint)" option is placed after the table in the from clause of the query. You can specify multiple locking hints by separating them with commas.

Following are the Locking Hints:

ReadUnCommitted, ReadCommitted, RepeatableRead, Serializable, ReadPast, RowLock, PagLock, TabLock, NoLock, TablockX, HoldLock, Updlock, XLock

The following query uses a locking hint in the from clause of an update query to prevent the
lock manager from escalating the granularity of the locks:

USE 'DatabseName'
UPDATE 'TableName'
FROM 'TableName' WITH (RowLock)
SET 'CoulmnName' = 'ColumnName' + ‘ Updated’

If a query includes subqueries, don’t forget that each query’s table references will generate
locks and can be controlled by a locking hint.






What do you think? Add your opinion/answer
*Name
*your opinion/answer: