patternsqlMinor
Manually deciding locking mode in MSSQL
Viewed 0 times
modemssqlmanuallylockingdeciding
Problem
In MSSQL, when a lock is acquired with a statement, the locking mode is decided by the engine not by the programmer. Is there a way to force the engine to use a specified Locking Mode (i.e. Row Lock)?
Solution
Sure, there are plenty of table hints, like:
However, you should use these with extreme caution. There are very few cases where the average programmer knows better than the engine, and forcing hints can cause more problems than they solve.
PAGLOCK
ROWLOCK
TABLOCK
TABLOCKX
However, you should use these with extreme caution. There are very few cases where the average programmer knows better than the engine, and forcing hints can cause more problems than they solve.
Context
StackExchange Database Administrators Q#198017, answer score: 8
Revisions (0)
No revisions yet.