O'Reilly logo

Microsoft® SQL Server 2012 Unleashed by Alex T. Silverstein, Chris Gallelli, Paul T. Bertucci, Ray Rankins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

Image 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:

Click here to view code image

declare @seqno intbegin transaction-- get a UNIQUE sequence number from sequence tableSELECT @seqno = isnull(seq#,0) + 1from sequence WITH (HOLDLOCK) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required