SSMS: Connect To Several Servers In One Click (Okay, Two)
November 24, 2012 in Management Studio, SQLServerPedia Syndication | No comments
I’ve been using the SQL Server Management Studio (aka SSMS) since it was first released with SQL Server 2005. And yet, it hasn’t stopped to surprise me. Earlier this week I’ve discovered a feature which I will use frequently as of now!
While doing my day-time job at the customer, I have a habit of connecting to several servers each time when I open SSMS. I always connect to them in the same order so that I can quickly locate them in the Object Explorer.
The servers I want open all the time are DEV DB server, DEV SSIS server, UAT DB server and UAT SSIS server. The SSIS servers are needed to get quick access to the Job Agent, while the DB servers are what I use all the time to actually do my job. To avoid confusion: on those SSIS servers, I’m connecting to the Database Engine, not the SSIS service.
So, earlier this week I was trying to find a method to easily connect to these servers with as few clicks as possible. And guess what: I found one! (Well, otherwise I wouldn’t be writing this of course.)
In the following paragraphs I’ll describe a method which you can use to connect to several servers at once, with just two clicks! I can tell you, it sure beats the Connect To Server popup window!
Screenshots taken using SQL Server 2012, but this should work as of 2005.
First we’ll create a group of all the servers that we’d like to connect to with just two clicks.
Open the Management Studio and switch to the Registered Servers view. If you can’t find it, use the menu to select View > Registered Servers or hit CTRL+ALT+G on your keyboard.

Right-click the Local Server Groups node located under Database Engine and select New Server Group… to create a new group.

Give it a good name and click OK.

Right-click the new group and select New Server Registration….
Enter the server credentials as appropriate.

What’s important here, besides the obvious such as entering correct credentials, is the Registered server name. The servers will be ordered alphabetically using that name, and that’s also the order in which they’ll be opened! So if you’re like me and you want your servers to be opened in a specific order, you’ll need some naming creativity or use numbers. In my case I’m glad that DEV orders alphabetically before UAT, which is what I want. ![]()
Ow, in case you’re wondering about that server name shown in the screenshot above, the dot refers to localhost and sql2012 is the instance name.
To demonstrate that I’m not joking, I’ll now register a second server and name it “Another server”. After clicking the Save button, here’s what the Registered Servers window displays:

As I told you, “Another server” is shown above “My DB Server” even though it was created later.
Now, what you’ve all been waiting for, how do I tell SSMS to connect to these servers?
Click number one is a right-click on the group name, My Favorite Servers in this case:

And click number two is the one on Object Explorer!
SSMS will now switch to the Object Explorer window and connect to the servers, in alphabetical order!

How’s that for a time-saver huh? I hope you’ll enjoy this as much as I will!
As a little extra, let’s quickly discuss one more feature of the Registered Servers window. When you right-click a group, you also get a New Query menu item. Clicking that will open a query window that’s connected to all the servers in the group. You’ll be able to tell because the database dropdown in the menu reads <multiple>:

And the status bar mentions the name of your server group and also <multiple>:
![]()
Having a query window connected to several servers at once let’s you do interesting things, such as quickly checking what version and edition you’re running on all those servers:

Of course, I’m sure I don’t need to remind you but I will anyway, this means it’s actually a dangerous window as well. In the database dropdown, you’ll get a list of all databases that are found on each server. There’s no advanced logic used in the process of building that list: if the database name is found on all servers in the group then the name of the DB is added to the list.
You can select one of those databases and execute queries against them, just like this:

The status bar will now mention the actual database it’s connected to, which is actually its regular behavior. And the messages pane will mention how many servers you’ve run the statement against.
In the case above, I created a table in two tempdbs on two servers. Imagine that I ran a DROP TABLE instead, and I forgot that one of the servers in the group was the production server on which I didn’t want to drop that table. So, be careful with those windows. To avoid errors, close them as soon as you’ve finished the job for which you needed them open!
Have fun!
Valentino.
Tags: Management Studio, SSMS
Certification



Recent Posts
- T-SQL Tuesday 42: Life, Change, Don’t Panic!
- Local Install of Books Online 2012
- Hidden Collections in SSRS
- How To Tweet About SQL Server Blog Posts
- Filtering Data Without Changing Dataset [SSRS]
- SSRS Deployment: Generate The Batch Script Through SQL!
- Connecting Shapes In Word
- Automating SSRS Deployment: Download
- SQLUG: Automating SSRS Deployments
- Shall We Join Or Shall We Split Now?
Tags
Categories
Archives
- May 2013 (2)
- March 2013 (3)
- February 2013 (2)
- January 2013 (2)
- December 2012 (2)
- November 2012 (3)
- October 2012 (2)
- August 2012 (2)
- July 2012 (2)
- June 2012 (2)
- May 2012 (2)
- April 2012 (3)
- March 2012 (4)
- February 2012 (4)
- January 2012 (2)
- December 2011 (2)
- November 2011 (2)
- October 2011 (1)
- September 2011 (3)
- August 2011 (2)
- June 2011 (2)
- May 2011 (3)
- April 2011 (3)
- March 2011 (3)
- February 2011 (2)
- January 2011 (5)
- December 2010 (1)
- November 2010 (3)
- October 2010 (3)
- September 2010 (2)
- August 2010 (4)
- July 2010 (2)
- June 2010 (4)
- May 2010 (6)
- April 2010 (3)
- March 2010 (3)
- February 2010 (11)
- January 2010 (9)
- December 2009 (2)
- November 2009 (3)
- October 2009 (3)
- September 2009 (4)
- August 2009 (6)
- July 2009 (2)
- June 2009 (3)
- May 2009 (7)
- April 2009 (3)
- March 2009 (3)
- February 2009 (5)
- January 2009 (4)
- December 2008 (2)
- November 2008 (3)
- October 2008 (1)
- September 2008 (1)
- August 2008 (4)
- July 2008 (3)
Tools You Really Need
Service Packs
SQL Server Material
- Common Solutions for T-SQL Problems
- Microsoft IT Showcase
- Microsoft Learning
- SQL Server 2008 Community Articles
- SQL Server 2008 MCM Readiness Videos
- SQL Server Books Online
- SQL Server Community Projects & Samples
- SQL Server Customer Advisory Team
- SQL Server Homepage
- SQL Server Library
- SQL Server TechCenter



No comments
Comments feed for this article
Trackback link: http://blog.hoegaerden.be/2012/11/24/ssms-connect-to-several-servers-in-one-click-okay-two/trackback/