title: After a Read Uncommitted query, do I have to set it back to Committed?
body: <p>Imagine executing a query using code similar to this here:</p>
  
  <pre><code>using (SqlConnection TheConnection = GetSqlConnectionNoCatch(SQLConnectionStr))
  using (SqlDataAdapter TheDataAdapter = new SqlDataAdapter(SQLStatement, TheConnection) { MissingSchemaAction = SchemaAction })
  {
      DataSet TheDataSet = new DataSet();
      TheDataAdapter.SelectCommand.CommandTimeout = SQLTimeout;
      TheDataAdapter.Fill(TheDataSet, TableName);
  
      return TheDataSet;
  }
  </code></pre>
  
  <p>And imagine having to read a database table that is absolutely getting pounded, non-stop, with writes, which leads to a lot of deadlocks and failures so you have to perform that read using a Read Uncommitted Isolation level.</p>
  
  <p>If my normal query was:</p>
  
  <pre><code>SELECT Field1, Field2 FROM Table WHERE some_type_of_clause
  </code></pre>
  
  <p>I often see that you would change it to:</p>
  
  <pre><code>SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
  SELECT Field1, Field2 FROM Table WHERE some_type_of_clause
  </code></pre>
  
  <p>OK, so here's what led me to ask this question, this particular link: <a href="http://blog.sqlauthority.com/2011/04/17/sql-server-applying-nolock-hint-at-query-level-nolock-for-whole-transaction/" rel="noreferrer">http://blog.sqlauthority.com/2011/04/17/sql-server-applying-nolock-hint-at-query-level-nolock-for-whole-transaction/</a></p>
  
  <p>His example has the following:</p>
  
  <pre><code>SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
  SELECT *
  FROM AdventureWorks.Sales.SalesOrderDetail sod
  INNER JOIN AdventureWorks.Sales.SalesOrderHeader soh ON
  sod.SalesOrderID = soh.SalesOrderID
  ORDER BY sod.ModifiedDate
  -- Set isolation level to original isolation level
  SET TRANSACTION ISOLATION LEVEL READ COMMITTED
  </code></pre>
  
  <p>Do I need to set it back to READ COMMITTED at the end of my query too?  Or is my read uncommitted only good for that one query?  Or maybe the life of the connection (which examining my code would mean as soon as I return the DataSet, as my Connection closes right then)?</p>
  
  <p>Most examples on the web leave out the 'set it back to original isolation level', so it puzzled me that he included it.  Thanks!</p>