How can I work on the same query if the connection is lost (timeout) and then I reconnect?
When I let the SQL session expire, I try to reconnect again and use the same query file I was working on, but it doesn't let me continue because it's says that I'm not connected to any database. So I have to restart the application, connect again and then the query will work.
Depends what you are doing. If you ran a stored procedure than it will finish but that also depends how you coded transaction handling in the stored procedure.
If you are just doing a simple select of an insert and the connection is broken. Then Sqlserver will rollback in case of an insert. A simple select will be terminated. If you want to guarantee the fact that you want to be able to work on after a connection loss then you should transfer your SQL into a stored procedure and in that stored procedure you program that the next time the stored procedure is executed ( after a connection loss) that it will continue the job it was doing by looking into a status table where it can pick up were it left.
To adjust the query timeout, access the server properties through the right-click menu, navigate to Remote server connections, and locate the remote query timeout field. Enter a large number in that field.
When this happens to me in SQL Server Management Studio, I just have to type USE {your database name here} and then select only that statement and execute it. This re-establishes my connection and I can continue to work on my query.
You can change the timeout for the query:
In the object explorer, right click a server and select properties.
Go to Remote server connections, look for the remote query timeout field; then type or choose a value from 0 to 2,147,483,647 to establish the maximum number secs that SQL Server will wait before timing out
SQL Server 2017 brings the power of SQL Server to Windows, Linux and Docker containers for the first time ever, enabling developers to build intelligent applications using their preferred language and
With over 2.5 million reviews, we can provide the specific details that help you make an informed software buying decision for your business. Finding the right product is important, let us help.
or continue with
LinkedIn
Google
Google (Business)
Gmail.com addresses not permitted. A business domain using Google is allowed.