When deploying database code, I'm running each SQL script on several servers, and having to click the "change connection" button dozens of times in SSMS is very frustrating. I submitted this as a bug to Microsoft, and Bill Ramos offered the following method for creating a keyboard shortcut:
- Open a Query Editor window connected to your favorite server.
- Right click on the Change Connection toolbar button on the Query Toolbar button and select the Customize command at the bottom of the menu.
- Right click on Change Connection button again and then change the command name "C&hange Connection..." to "Chan&ge Connection...". This will change the hot key from Alt-H (which would conflict with the Help menu hot key) to Alt-G.
- Finally, in the Right Click menu for the Change Connection button, you need to select the command option to display both "Image and Text". This exposes the Alt-G command to the Query Editor.
- You can now close the Customize dialog and use Alt-G as your hot key!
I love this shortcut. I use it dozens of times daily. It's still too much overhead for deploying, though, so I either use Query Analyzer (open a window, drag all the files into it, and they all open with a connection to that same server without prompting) or an application I wrote to accept a deploy list, get the files from our source control provider, and put them all into one script with appropriate USE [database] statements.
Labels: SQL Server, SQL Server - SSMS