r/SQLServer • u/RobertWF_47 • Sep 09 '25
Solved Increasing connection time-out in SQL Server Management Studio?
I'm running a long SQL program in SSMS that is taking > 24 hours to run, and am finding my session times out if left running more than a few hours & I lose my work. (A separate issue: the IT in my company only lets us create temporary tables, not permanent, on the SQL server.)
Clicking on File -> Connect Object Explorer... -> Options>>, I see the default connection time-out setting is only 30 seconds, which seems pretty low.
Can we increase connection time-out setting from 30 seconds to an arbitrarily large value to prevent time-outs?
9
u/alinroc 4 Sep 09 '25
If your query is taking "more than a few hours" and then your session is "timing out", then changing the connection timeout isn't your solution. You are getting connected, and staying connected. That timeout setting is for how long SSMS will wait on establishing a connection before giving up.
I think it's far more likely that your DBAs are killing long-running queries, either manually in response to an alert (most monitoring suites will flag this) or with an automated process killer that's picking it up and killing it after X amount of runtime.
That's a good thing, for both security and resource management. Try creating a permanent table in tempdb. Not a
#temptable, an actual table. It'll probably work, unless your DBAs have really put the screws to the system. Just make sure you clean up after yourself when you're done.5
u/stedun 2 Sep 09 '25
I dare ask, what are you doing that takes >24 hours to run in the database?
I could migrate a whole data center in 24 hours.
11
u/BrentOzar Sep 09 '25
The connection timeout only controls how long SSM waits when calling SQL Server to establish the connection, not how long it will wait for query results.
To prove that, run a query that does a WAITFOR DELAY “1:00:00” and watch it work.
4
u/ATHiker2025 Sep 09 '25
Try running your SQL program in a SQL Agent job.
2
u/Prestigious_Flow_465 Sep 10 '25
It's very weired your case. Doesn't make much sense.
Do you have read only access to the data? Perhaps you can install Postgres on your local pc or python+duck db?
Is the sql server on premise or cloud?
1
u/Codeman119 Sep 11 '25
Set the time out to 0