Update: Now with Object Explorer shortcuts!

One of the most common things I do within SSMS is to change connection for the current query editor window, from one SQL Server instance to another:

I’m a huge fan of keyboard shortcuts (see exhibit 1, exhibit 2, and exhibit 3). So let’s create a shortcut for “Change Connection” today.

The basic method for creating keyboard shortcuts is:

Select Tools > Options > Environment > Keyboard. Use the search bar “Show Commands Containing” to find and select the command. In this example, we’re looking for Query.ChangeConnection.

In “Press Shortcut Keys”, press the shortcut combination you want to use. In this example I’m using Ctrl-K, CTRL-O.

Click Assign. If you don’t click Assign, and just click OK, your shortcut won’t be assigned. Click OK. (Note that some shortcut changes take effect in query windows you open after the change.)

Now, to change the connection for the query window, I have my shortcut!

Object Explorer Shortcuts

The next most common thing I do in SSMS – which doesn’t have a shortcut – is to open new connections to, and disconnect from, SQL Server instances within Object Explorer. Let’s create shortcuts for these, shall we?

Using the same method as above, we find that the Obect Explorer Connect command we’re looking for is File.ConnectObjectExplorer:



That sort of makes sense, as “Connect Object Explorer” is the first item under the “File” menu. I’ve assigned CTRL-O-O as the shortcut. (Get it? As in, CTRL-Objectexplorer-Openconnection.)

I do the same thing for Object Explorer Disconnect, for which the command turns out to be “File.Disconnect”:

And there we are! Look under the File menu, and you can see your new shortcuts displayed next to their corresponding options: