Tuesday, September 17, 2013

Setting Different Colors for Connections in SSMS




SQL Server 2005 introduced a great new feature to help users quickly look at their tabs and understand which connection that a tab is currently using. For those of us who frequently work on many different servers at the same time, this is a job-saving feature that helps us quickly look at the color to determine which server we are currently using.

Setting a Color for a Connection

First, open SSMS. Next, if it's not already open, open the "Registered Servers" panel using Ctrl+Alt+G or select the "Registered Servers" item in the View menu. As shown below, you see a number of servers listed.
Now you can right-click a registered server in the list and select "Properties" as shown below.
Select the "Connection Properties" tab and click the checkbox next to "Use custom color:". This is at the bottom of the dialog you see here.
Click the "Select" button to bring up the "Color" dialog window. This is the standard Windows color picker, with basic colors shown in the image below.
For our "Local" connection, choose a color that is appropriate for you. I'll choose the blue in the top row 3rd from the right. When you're satisfied with your selection, hit "OK".
Your selected color will now appear in the box next to the "Use custom color" option. If you are satisfied with your choice, click the "Save" button. If not, click the "Select" button to repeat the last two steps until you are content with your color choice.
If you wish to stop using that custom color for that server, go back to the registered server properties and uncheck the "Use custom color" option.

Verifying the Connection Colors

Once you've set your connection colors, it would be good to know that they work. To test, right-click one of the servers for which you set a connection color and select "New Query". You can see the different colors below for "Development", "Local", and "Production" (in order). You can even change your connection in SSMS for SQL 2012 and the color will change to the one for the new connection.
In SQL 2005, there was an undocumented feature when changing connections for a window. The color would not change. This has been fixed in SQL 2012. Be aware that if you're still using SSMS from SQL 2005, you will want to be careful when changing connections because the colors will not change as expected.
In the first image below, you see I have a green color selected for one server. The two images below that show blue and red highlights in the status bar.

Other Options

You're probably looking at those screenshots and wondering if it's possible to have the color show up in a different location or even change the color of your tabs to reflect your environment. There are a couple of options to let you do this, but there is a cost associated with each.
SSMS Tools Pack is the least expensive option. It runs 25 Euro for a single-user license and is well worth the cost. That cost only applies to SSMS 2012 or higher. For SSMS 2005 and 2008 there is no charge. Here is an example of setting the connection coloring to the Top position within your window. This can be set for as many connection strings as you want to use and can be changed for each connection string.
Red-Gate's SQL Prompt costs a bit more, but adds in some great TSQL Auto-complete and Formatting functionality that makes it worth the price. Recently added to the features is an option to change the tab color based on environment. The only drawback is that SQL Prompt's colors are limited to 4 choices at this time - Development, Production, Testing, and Staging. There is no option to customize the colors for those choices. However, it's a great way to see the colors for each tab. Here is an example of using both SQL Prompt's tab coloring and SSMS Tools Pack's connection coloring.

No comments:

Post a Comment