SSMS hangs for an extended period when closing a query tab or object explorer when a connection cannot be established to the SQL Server

allmhuran 136 Reputation points
2022-03-15T17:09:44.58+00:00

Suppose I am connected via VPN to a network that includes a SQL server.
I then open SSMS and connect to that server.
Eventually the VPN loses connection or I disconnected (work is finished for the day, whatever)
I then attempt to close an SSMS query window, or close the SSMS application.

At this point, SSMS will hang, becoming completely unresponsive. It seems as though it is trying to create a connection to the now unreachable server. I assume that this attempted connection eventually times out, because after a while SSMS starts responding again and the query window closes. At no point is any kind of error shown.

I don't see any reason why SSMS should be attempting to make a connection to the SQL Server when I am just closing a query window. If I was attempting to execute a query that might make sense, but not to just close a tab, or close SSMS as a whole.

This is currently happening on SSMS 18.6 but has been happening for multiple versions now. It has become a particular nuisance with significantly more work being done remotely via VPN.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,019 questions
{count} votes

Accepted answer
  1. Erland Sommarskog 112.7K Reputation points MVP
    2023-01-26T19:57:49.4066667+00:00

    SSMS 19 was released today. And there is no an option to turn off this question, see below. Note that the checkbox is checked by default. I unchecked first thing when I got SSMS 19 installed.

    User's image

    6 people found this answer helpful.

8 additional answers

Sort by: Most helpful
  1. Erland Sommarskog 112.7K Reputation points MVP
    2022-03-15T22:41:16.53+00:00

    When you close the window, SSMS issues "SELECT @@trancount" to see if you have any open transaction, so it can alert you if you have. Keep in mind that SSMS is not aware of that the connection has gone dead, so it will try to run the query (and eventually give up).

    Yes, it happens to me many times. I always make the mistake when it is time to close down everything before I restart to complete a Windows update. I first close my VMs and I close the query window connected to the VM. Or I keep a window open to my serverless Azure SQL database, and when I close the window, the database has been shut down.

    If you would like to have an option to skip this check, you could file a suggestion on https://feedback.azure.com/d365community/forum/04fe6ee0-3b25-ec11-b6e6-000d3a4f0da0. Be sure to include why you want that change and the business impact, because this is important for Microsoft.

    5 people found this answer helpful.

  2. Dan Espich 41 Reputation points
    2022-08-03T19:56:24.017+00:00

    Yea I am confused on this. If it's something that has always been done when you close a window/connection why does it suddenly make you click "close" on the notification? It's a extra unneeded click, I don't really care to know that "Querying transaction count" is complete, just close the window or give me the prompt to save changes or not.

    3 people found this answer helpful.

  3. Naomi Nosonovsky 7,886 Reputation points
    2022-03-15T19:20:16.957+00:00

    Hi,

    I can only confirm that I also observed this behavior (even in SSMS 18.10). If I left a query window opened and accidentally try to execute it after not having a connection to the server, closing the file or cancelling the query takes a long time. And just saving the file (without even executing) may also take a very long time.

    0 comments No comments

  4. AmeliaGu-MSFT 13,986 Reputation points Microsoft Vendor
    2022-03-16T02:47:50.243+00:00

    Hi allmhuran-6523,
    Please also try to use SSMS 18.11.1 to see if the issue have been solved.
    If the issue persists, suggest you submit the issue to Microsoft feedback website as Erland mentioned.
    Your feedback is valuable for Microsoft to improve the level of products and service. Appreciate for your understanding.
    Best Regards,
    Amelia


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.