Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When you perform the <code>select</code>, place a <code>updlock</code>, <code>holdlock</code> on the range being selected:</p> <pre><code>begin transaction if not exists( select id from [ua_subset_composite] with (updlock, holdlock) where ua = 'sadsadsad') begin insert into [ua_subset_composite] select 'sadsadsad',1,null,null,null,null end commit </code></pre> <p>The <code>holdlock</code>, equivalent to the <a href="http://msdn.microsoft.com/en-us/library/ms173763.aspx" rel="nofollow"><code>serializable</code> isolation level</a>, will have the following effect:</p> <blockquote> <ul> <li><p>Statements cannot read data that has been modified but not yet committed by other transactions.</p></li> <li><p>No other transactions can modify data that has been read by the current transaction until the current transaction completes.</p></li> <li><p>Other transactions cannot insert new rows with key values that would fall in the range of keys read by any statements in the current transaction until the current transaction completes.</p></li> </ul> <p>Range locks are placed in the range of key values that match the search conditions of each statement executed in a transaction. This blocks other transactions from updating or inserting any rows that would qualify for any of the statements executed by the current transaction. This means that if any of the statements in a transaction are executed a second time, they will read the same set of rows. The range locks are held until the transaction completes. This is the most restrictive of the isolation levels because it locks entire ranges of keys and holds the locks until the transaction completes. <strong>Because concurrency is lower, use this option only when necessary</strong>.</p> </blockquote> <p>The <code>updlock</code> is needed in addition to the <code>holdlock</code>... by adding the <code>updlock</code> we prevent a separate process from performing its own <code>select with (updlock, holdlock)</code> statement on the same range at the same time.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload