title: Query timeout error Excel VBA
body: <p>I'm trying to run a SQL Server query via Excel VBA which gives me below error.
  I have tested this query in SQL Server Management Studio &amp; it working perfectly fine. It takes about 4 mins to run in SSMS, but fails via VBA. I have already tried increasing the timeout up to 600 secs &amp; setting it to zero as well.</p>
  
  <p>Surprising part is if I debug my VBA &amp; copy the script from it (since it's generated @ runtime based on different values) even that run perfectly after pasting in SQL Server Management Studio? </p>
  
  <p><a href="https://i.stack.imgur.com/uPasG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uPasG.jpg" alt="enter image description here"></a></p>
  
  <p>What am I missing here? Any pointers would be highly appreciated...</p>
  
  <p>PS: if I run another query with same piece of code, it runs correctly!</p>