Transaction Isolation–Level Hints

SQL Server provides a number of hints that you can use in a query to override the default transaction isolation level:

HOLDLOCKHOLDLOCK maintains shared locks for the duration of the entire statement or for the entire transaction, if the statement is in a transaction. This option is equivalent to the Serializable Read isolation level. The following hypothetical example demonstrates the usage of the HOLDLOCK statement within a transaction:

image

Note

As discussed earlier in this chapter, in the “Deadlocks” section, using HOLDLOCK in this manner leads to potential deadlocks between processes executing the transaction ...

Get Microsoft® SQL Server 2008 R2 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.