With many mistakes made by developers and DBAs alike firing a query in a wrong environment, there is one easy thing that can be done to alleviate this problem. That is by using the color coding on the status bar and you can set this up in the server registration on your SQL Server Management Studio (SSMS).
This feature is so easy to overlook because many people just don’t bother to look at the second tab when editing the Properties in Server Registration (in fact, quite a few people don’t bother to use Registered Servers at all to connect to the databases).
On the Registered Servers pane on SQL Management Studio, right-click on the server you want to assign a color and select Properties…
Click on the Connection Properties tab and check on Use custom color:
Here are the color schemes I use for the example. Feel free to use any colors that suit you.
Environment (RGB values)
DEV (102, 133, 46)
STAGING (128, 128, 0)
QA (255, 128, 0)
PROD (190, 0, 0)
Do these steps for all database servers you want to color code.
Here is the final result with all windows opened.
Caveats
- You need to use the registered servers in order to use the custom color.
- For some reason, the custom color settings is not exportable. So you have to take note of your color settings and repeat the steps for any other computers you use.
If you use Change Connection button, the color will stay the same as the last one you connected to from the registered servers, which can be dangerous.This can be remedied by using connection coloring in SSMS Tools Pack. This issue was fixed in Windows 8.1, however SSMS Tools Pack still gives a bit more flexibility to place the color bar on one of the four sides of SSMS query window. If you have access to Redgate SQL Prompt, this might be the best option, and you can read on how to do it here.
Further Reading
How to Use Custom Color in SSMS Using Redgate SQL Prompt
Using Connection Coloring in SSMS Tools Pack
Adam Plocher says
This is a great feature – I’ve been using a similar feature in SQL Prompt for quite a while and never knew that it was actually built into SQL Manament Studio. The Redgate SQL Prompt version colors the tabs (which is a little bit nicer because you see which environment all your tabs are working against), but it’s not easy to configure the colors and you need a SQL Prompt license.
My main question is: is there a way in SQL or even on a domain controller to somehow set a policy that says “this instance is this color” so EVERYONE (even certain… error prone co-workers…) will automatically get colorized?
platt says
Hi Adam,
I don’t think it can be setup that easily across the board. However, if you’re an admin, a pre-configured RegSrvr.xml file can be set as part of an image for a new deployed PC.
For existing users, there’s more work involved to locate this file usually in %USERPROFILE%\AppData\Roaming\Microsoft\Microsoft SQL Server\###\Tools\Shell folder (### being your SQL Server folder version number) and modify the parameters. Basically it’s doable with some scripting and file push over the network.
I hope that answers your question.