title: Select data from a table while update is running within a transaction in SQL Server
body: <p>The following sql query is used to update a specific row inside transaction.  </p>
  
  <pre><code>BEGIN TRANSACTION;  
  
  Update [dbo].[StudentExamAttendanceDetails]   SET StudentFeedBack = 1 Where Id = 4883174
  
  COMMIT TRANSACTION;
  </code></pre>
  
  <p>The problem is until the transaction is committed the whole table remains locked. So I can not select any data from the same table at the same time.</p>
  
  <p>For testing purpose, I ran the following portion of the query skipping the <code>COMMIT TRANSACTION;</code> part:</p>
  
  <pre><code>BEGIN TRANSACTION;  
  
  Update [dbo].[StudentExamAttendanceDetails]   SET StudentFeedBack = 1 Where Id = 4883174
  </code></pre>
  
  <p>At the same time I ran the select query. As the whole table is locked, the select query can not select any data. When I run the commit code:
  <code>COMMIT TRANSACTION;</code> on the update query then the select query is working. But I am trying to run the select query while the update transaction is not yet committed. That means I only want to lock the row that is being updated not the whole table.
  So I tried two ways:</p>
  
  <pre><code>1. GO  
     SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; 
  
  2. Update [dbo].[StudentExamAttendanceDetails] With(RowLock)  SET StudentFeedBack = 1 
     Where Id = 4883174
  </code></pre>
  
  <p>But none of these methods is working. The whole table is still locked and I can not select any data from the table until the transaction is committed.</p>