title: SQL Server Query Time Out
body: <p>A 3rd party application accessing a SQL Server 2012 database is getting <code>[Microsoft][ODBC SQL Server Driver]Query timeout expired</code> errors after executing for about 20 mins.</p>
  
  <p>This is what I see on the database after the application starts receiving the errors:</p>
  
  <p><img src="https://i.stack.imgur.com/Bg0xn.png" alt="Query Screenshot -1"></p>
  
  <p>SPID 102 is not shown in the query above. It is another connection from the same application for the same process. I was able to capture some details of this in the screenshot below. It is the one in the topmost row in this screenshot. Apologize that the scrollbar was moved to the right when taking the screenshot.</p>
  
  <p><img src="https://i.stack.imgur.com/zN5aB.png" alt="Query Screenshot - 2"></p>
  
  <p><code>AutoShrink</code> was set to <code>TRUE</code> on this database when this occurred. </p>
  
  <p>It looks like:</p>
  
  <ul>
  <li><p>several connections from the 3rd party application which started later on are waiting on SPID 27 - which is an AUTOSHIRNK command</p></li>
  <li><p>SPID 27 is waiting on SPID 102 which is another connection from the same 3rd party application</p></li>
  </ul>
  
  <p>Question:</p>
  
  <ul>
  <li><p>Is there any way to tell if the connection with SPID 27 created since <code>AutoShirnk</code> was set to <code>TRUE</code> on the database? </p></li>
  <li><p>If so, why does it wait on SPID 102 and why are the other connections (83,85,86,88 and 90) waiting on 27?</p></li>
  </ul>
  
  <p>According to the TechNet article in the link below, AutoShrink shouldn't have an impact on any activity on the database</p>
  
  <blockquote>
    <p>If a database has the AUTO_SHRINK option set to ON, the Database
    Engine reduces the size of the files in the database. This activity
    occurs in the background and does not affect any user activity within
    the database.</p>
  </blockquote>
  
  <p><a href="http://technet.microsoft.com/en-us/library/ms189080%28v=sql.105%29.aspx" rel="nofollow noreferrer">Shrinking a Database</a></p>
  
  <p>Notes:</p>
  
  <ul>
  <li><p>This is currently running on SQL Server 2012 SP1 where this issue occurs.</p></li>
  <li><p>This process in the application works ok when the application runs off a database on SQL Server 2008 SP3.</p></li>
  </ul>