title: Which SQL Read TRANSACTION ISOLATION LEVEL do I want for long running insert?
body: <p>I have a long running insert transaction that inserts data into several related tables.  </p>
  
  <p>When this insert is running, I cannot perform a select * from MainTable.  The select just spins its wheels until the insert is done.  </p>
  
  <p>I will be performing several of these inserts at the same/overlapping time.  To check that the information is not inserted twice, I query the MainTable first to see if an entry is there and that its processed bit is not set.  </p>
  
  <p>During the insert transaction, it flips the MainTable processed bit for that row.</p>
  
  <p>So I need to be able to read the table and also be able to tell if the specific row is currently being updated.</p>
  
  <p>Any ideas on how to set this up in Microsoft SQL 2005?  I am looking through the <a href="http://msdn.microsoft.com/en-us/library/ms173763.aspx" rel="nofollow noreferrer">SET TRANSACTION ISOLATION LEVEL</a> documentation.</p>
  
  <p>Thank you,<br>
  Keith</p>
  
  <p><b>EDIT:</b>  I do not think that the same insert batch will happen at the same time.  These are binary files that are being processed and their data inserted into the database.  I check that the file has not been processed before I parse and insert the data.  When I do the check, if the file has not been seen before I do a quick insert into the MainTable with the processed bit set false.  </p>
  
  <p>Is there a way to lock the row being updated instead of the entire table?  </p>