PowerShell – Invoke-Sqlcmd -QueryTimeOut Broken

Sample Code

   $sqlInstance = "DBPlayground";
   $query = " exec longrunningQuery";
   $qt = 0;

   $objResults = Invoke-SqlCmd - Query $query -ServerInstance $sqlInstance -E -querytimeout $qt



Though, we are passing along a Query-Time of 0, it is not “respected”.

Specifying the max value of 65534 seems will work.  Note that:

65334 (secs) / 60  --> 1092 (minutes)

Please check http://connect.microsoft.com/SQLServer/feedback/details/551799/invoke-sqlcmd-querytimeout-0-still-times-out and review the 1st Workaround ( the one submitted by cmille19) for a much need needed & elegant work-around.


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s