title: SQL Server 2008 - Update Query Timeout
body: <p>I'm using SQL2008 and .NET 4.</p>
  
  <p>The following <strong>UPDATE</strong> query causes timeout errors.</p>
  
  <p>Table <strong>Pages</strong> has 600,000 records.</p>
  
  <p>Error:</p>
  
  <blockquote>
    <p>System.Data.SqlClient.SqlException
    (0x80131904): Timeout expired.  The
    timeout period elapsed prior to
    completion of the operation or the
    server is not responding. </p>
  </blockquote>
  
  <p>Query:</p>
  
  <pre><code>UPDATE  Pages
  SET Checked = 1  , LastChecked = GETDATE()
  OUTPUT Inserted.ID, Inserted.Title INTO @Updated
  WHERE ID in 
   (SELECT TOP (@Count) ID 
    FROM Pages 
    WHERE Checked = 0 and FileID = @FileID 
    ORDER BY ID)
  
  SELECT * FROM @Updated  
  END
  </code></pre>
  
  <p>On a different thread I Insert records to <code>Pages</code> table, this runs continually (a page is added every 1 sec or less). </p>
  
  <pre><code>INSERT INTO Pages (Title ,.......)
  VALUES (@Title , .......)
  </code></pre>
  
  <p>Why do I get the timeout error and how can I solve it?</p>
  
  <p>Doesn't SQL wait indefinitely on blocking situation ?</p>