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.
- 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.