Color Code Your SSMS Windows With the SSMS Toolpack

If your typical workweek is anything like mine you might have connections to multiple SQL Server instances open in SQL Server Management Studio at any given time. For me, some of these instances are on my local machine (i.e. I use them for development work), and some of them are on remote (read: test or production) machines. In a perfect world I’d never need to jump into a production database to investigate an issue, but the world I live in is far from perfect so I end up looking at “live” databases from time to time.

Because I can sometimes have multiple connections going at once I always have a little voice in the back of my head asking, “Am I about to run this query against the wrong instance?” I usually like to keep connections to remote machines open only for as long as I need them to help mitigate that risk but in my imperfect world sometimes I get distracted by a phone call or IM. I’ve done a pretty good job of conditioning myself to take a quick peak at the status bar at the bottom of my SSMS query window to make sure that the server says what I think it should before kicking off any query that will alter data or cause locking.


I was doing some screen-sharing with a co-worker the other day and noticed that he had a little colored bar at the top of his query window. Turns out that he was using the Window Connection Coloring feature in the SSMS Toolpack (which is a great add-in for SQL Server Management Studio). This feature lets you have a color-coded bar present in every query window that changes based on what server that window is pointed at.

If you have the SSMS Toolpack installed just go to the “SSMS Tools –> Window Connection Coloring –> Options” menu to bring up the dialog for configuring your connection highlight settings. I set up mine to look something like this:


Rather than setting up a different entry for every server I connect to, I setup two entries:

  • One for ‘localhost’ that uses a green connection color.
  • One using a regex for any server name that isn’t ‘localhost’ that uses a red connection color. The regex I used is: ^((?!localhost).*)$ (also be sure to check the ‘IsRegex’ column).

This dialog UI is a bit wonky, so make sure that you click the ‘Save’ button once you get everything the way that you want it before clicking ‘OK’.

With these settings I now have a bright green bar at the top of every query window that is pointed at ‘localhost’ and a bright red one that is pointed at every other server I connect to. Now I know that I don’t want those red windows open for very long!

Happy Green Window (localhost):


Scary Red Window (remote machine):