Tuesday, January 22, 2013

Table hint basics

SELECT columnlist FROM myTable WITH (TABLOCK);

Generally avoid table hints and let SQL Server manage locking.
Exact behaviour depends on the isolation level.
  • TABLOCK - Shared table lock
  • TABLOCKX - Exclusive table lock
  • NOLOCK - Like the READUNCOMMITTED isolation level.
  • UPDLOCK - Use update locks
  • XLOCK - Take exclusive locks

Full list at MSDN

No comments: