#0197-SQL Server-SSMS-Disconnect all queries feature


Have you ever been in a situation wherein you have been working furiously on your SQL Server Management Studio (SSMS) on multiple query windows and you need to rush out to a meeting? As you know, each query editor window within the SSMS opens a new connection to the SQL Server. Open connections mean more resources being consumed at the server. Hence, when going into a meeting or lunch, one may not want to keep these connections open. I don’t.


So, what do I do in such cases?


The answer is simple: I use the “Disconnect all queries” feature available in the SSMS query editor right-click context menu. Here’s a short demo.


As you can see in the screen-shot below, I have 4 queries open – each connected to a different SQL server instance (to cycle through the open queries, simply use the Ctrl+TAB keyboard shortcut).


image


Now, to disconnect all queries from the corresponding SQL Server instances in one go, right-click in the query editor window, go to Connections->Disconnect all queries.


image


Upon clicking “Disconnect all Queries”, notice that the tabbed document spaces for all queries are now reading “not connected”.


image


I personally don’t like to reopen the SSMS often – it’s launched once in the morning, and the only time I close it is when I shut down my laptop in the evening.  Having a “disconnect all queries” is a cool little feature that comes in very handy.


Hope you like it as much as I do! Do you know of any cool features within SSMS? Do let me know!


Until we meet next time,


Be courteous. Drive responsibly.

Advertisement

1 thought on “#0197-SQL Server-SSMS-Disconnect all queries feature

  1. gorthims

    Very Useful. You can also do this using following main menu.

    **Q**uery –> **C**onnection –> Disconnect **A**ll Queries

    The keyboard shortcut is **Alt+Q, C, A**

    Like

    Reply

Let me know what you think about this post by leaving your feedback here!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.