Does anyone know how to set Invoke-SqlCmd QueryTimeout more than 65535?
Microsoft said that they have fixed it in Denali but we are still using SQL 2008 R2 with latest service packs.
Basically, we are trying to backup or restore the database using powershell. Some of our databases are very large so it takes more than 65535 to complete the job.
Some suggested that we should use ADO.NET with timeout in powershell. But I wonder if we have any workaround for Invoke-SqlCmd…
You can write your own version of Invoke-SqlCmd that directly uses the System.Data.SqlClient object and do anything that you want to with it. There are a bunch of examples of how to do this to be found, including invoke-sqlcmd2, which was specifically written to get around the QueryTimeout bug and is hosted on Microsoft’s scripting gallery. If you don’t want to deploy such a script, you can just integrate the relevant code directly into your backup script.
Alternatively, you should be able to use SMO to backup the database. IIRC, the querytimeout bug does not affect SMO.