Using Custom Connection Colors in SSMS

One of the new features that was added to SQL Server Management Studio (SSMS) in SQL Server 2008, which was continued in SQL Server 2008 R2, is the ability to set custom connection colors for individual instances of SQL Server. The color you set shows up in the bottom of the query window in SSMS. This allows you to do things like set red for Production instances and green for development instances.

In order to get this to work reliably, you need to set it in two different places in SSMS. First, the Connect button in the toolbar. You have to switch to the Connection Properties tab, and set the “Use custom color” for that instance. Next, you need to go to that same instance under Registered Servers, and then set the same color on the Connection Properties tab.

This will make SQL Server use that custom color whether you you are opening a new connection or changing an existing connection. If you don’t set the custom color in both locations, you will probably run into issues where the color does dot always change as you expect it to.

This entry was posted in SQL Server 2008 R2. Bookmark the permalink.

9 Responses to Using Custom Connection Colors in SSMS

  1. Chad says:

    Glenn,You can also use PowerShell to set the connection color property (useful if you want to change the connection color on many servers). ince the color attribute is stored as number lookup the number,set the connection color in SSMS for one server. Lookup the connection color using PowerShell and sqlps. In this example I cd to a server group named MyGroup and list the connection color information for all serves in that group.cd \’SQLSERVER:\\SQLRegistration\\Database Engine Server Group\\MyGroup\’ dir | select name, usecustomconnectioncolor, CustomConnectionColorArgbFinally cd to the server group you want to change the color connection. Run dir again, specifying use custom color and the color number. Changing some SMO properties including connection information require running the alter method. In addition you may need to close and re-open SSMS for the changes to take effect.cd \’SQLSERVER:\\SQLRegistration\\Database Engine Server Group\\MyGroup\’ dir | foreach {$_.usecustomconnectioncolor = $true; $_.CustomConnectionColorArgb = -65536; $_.alter()}Note: There is a bug in CMS where connection color information is not retained. The bug occurs whether you set the color information using SSMS or sqlps. This does not effect servers registered locally. I have a connect item filed, please vote:https://connect.microsoft.com/SQLServer/feedback/details/534283/connection-properties-are-not-retained-when-servers-are-registered-under-a-central-management-server

  2. Glenn says:

    Wow, that is a nice solution for automating the changes.

  3. Chad says:

    Thanks — I\’m going to copy my comment your SCC blog syndication also.

  4. paschott says:

    May be worth throwing in a reference to Mladen Prajdic\’s SSMS Tools Pack – http://www.ssmstoolspack.com . He\’s done a good job of throwing together a lot of different features and when you set up a color in his tool set, it handles changing on connection very nicely. I\’m still glad to know that it has to be set in multiple places for it to work properly, though. I often use the Query – Change Connection option and would have my color indicating I was still in a Dev environment when actually connected to a production server when trying to use the native color changing.Chad – great snippet for Powershell. I\’ll have to add that to my list of tricks.

Leave a comment