title: How to implement Serializable Isolation Level in SQL Server
body: <p>I need to implement a serializable isolation level in SQL Server but I've tried many ways and I don't get it.</p>
  
  <p>I need to lock 1 row in one transaction (It doesn´t matter if lock the complete table). So, another transaction can´t even select the row (don´t read).</p>
  
  <p>The last thing I tried:</p>
  
  <p>For transaction 1:</p>
  
  <pre><code>SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  BEGIN TRAN
  
  SELECT code FROM table1 WHERE code = 1
  
  -- Here I select in another instance the same row
  
  COMMIT TRAN
  </code></pre>
  
  <p>For transaction 2:</p>
  
  <pre><code>BEGIN TRAN
  SELECT code FROM table1 WHERE code = 1
  COMMIT TRAN
  </code></pre>
  
  <p>I would expect that transaction 2 wait until transaction 1 commit the operation, but the transaction 2 gives me the row.</p>
  
  <p>Anyone can explain me if I miss something?</p>