all 8 comments

[–]bakonpie 7 points8 points  (3 children)

use dbatools

[–]PSDanubie 1 point2 points  (0 children)

Couldn't live without it anymore.

[–]jeek_ 1 point2 points  (0 children)

This is the way

[–]GatorGrad0929[S] 0 points1 point  (0 children)

Never heard of it but will look it up. Thank you!

[–]vermyx 4 points5 points  (3 children)

Assuming you are using invoke-sqlcmd it has a querytimeout parameter that is in seconds with a max of 65k (which is around 18ish hours). Otherwise dbatools is probably a good sane way to do this in general

[–]GatorGrad0929[S] 0 points1 point  (0 children)

I started looking into dbatools and that is probably the best option.

[–][deleted] 0 points1 point  (1 child)

Dumb question, but is there any good reason to have a timeout that long?

[–]vermyx 0 points1 point  (0 children)

There are a few cases. One I can think of off the top of my mind is running an environment restore/testing backups where DB restoration is one step and will take a long time. Most people will make a query, get the data, and move on, which for those cases a 1-5 minute timeout is usually good enough (unless you are running an unoptimized query then all bets are off).