title: Which Isolation level should i use for booking flight
body: <p>I have a flight reservation program use mssql
  ,For reserving flights i want to be sure should i use isolation level or locks?</p>
  
  <p>(this is a sample code,my problem is Isolation Level for this situation not do the reservation)</p>
  
  <p>My Database has a table for inventory like:</p>
  
  <pre><code>Inventory Table
  ------------------------
  id (Pk),
  FlightNumber,
  Total,
  Sold
  </code></pre>
  
  <p>now if some want to reserve a flight,i use this code in transaction</p>
  
  <pre><code>Decalre @total int;
  Decalre @sold int;
  Select @total=Total,@sold=Sold From Inventory where FlightNumber='F3241b';
  
  IF @total-@sold &gt; 0
  BEGIN
     Update inventory set Sold=Sold+1 where FlightNumber='F3241b';
     PRINT 'Reserve Complete'
  END
  ELSE
  PRINT 'this flight is full' 
  </code></pre>
  
  <p>i have these Question:</p>
  
  <p>Q1: Should I use Locks or Isolation Levels?does it have any benefit for perfomance to use one?</p>
  
  <p>Q2: according to Q1 Which Isolation Level or Lock should i use</p>