Assign Colors in SQL Server Management Studio Query Windows Based on Environment
There is always a risk of error when you have a very high workload with multiple query windows in a single SQL Server Management Studio session. Here I will discuss how to assign a different color to each server connection for your query windows. This way we can minimize the risk of running the wrong T-SQL code on the wrong server.
Generally, a DBAs job is very hectic; sometimes you have to work on multiple query windows which are connected to multiple SQL Server instances. The risk of making an error (like running T-SQL code on the wrong instance) might be high as your stress level grows. Although every query window in SQL Server Management Studio (SSMS) includes information about instance name and user name, there is still a risk of running the wrong code.
As a professional, we should always try to reduce the complexity and minimize the risk of error. In this tip, I will show how to assign colors to different server connections, so that you will be fully aware you are running your code in production vs. a lower life cycle environment.
Assign colors to SQL Server Instances in SSMS
Since we keep all servers registered in SQL Server Management Studio, launch SSMS and go to "Local Server Groups" where all registered SQL Server instances are present.
Select the server name for which we are intending to set the color. Right click on that server and choose properties as shown in the below screenshot.
A property window will appear with the name "Edit Server Registration Properties". Go to the Connection Properties tab. There is a setting called "Use custom color" in the Connection section of that window. Tick the checkbox for this setting.
Now click on the "Select..." button next to this setting. Another window named "Color" will appear. Choose the color you want to assign to the query connections for this instance and then click OK. I selected blue for this server.
Now click on the OK button of the "Edit Server Registration Properties" window to apply the changes.
Now that the color has been set, you can verify it by opening a new query window. I set blue for this server, so now let's verify whether this change has been applied. When I click on "New Query" in SQL Server Management Studio, a new query window opens and you can see in the below screenshot that the bottom status bar is set to blue.
Setting Colors when Registering New Servers
We can also make these changes during the registration of SQL Server Instances. We need to click on the "Options" tab in the connection window then click on the Connection property tab. After this you can follow same steps above. Here is another tip with step by step instructions - Customizing the Status Bar for each SQL Server SSMS Connection.
- Setup these connection properties in your SQL Server Management Studio environment to help reduce the risk of running the code against the wrong environment. Consider the following color scheme:
- Your Personal Sandbox = Green
- Development = Blue
- QA = Yellow
- UAT = Orange
- Production = Red
- Check out these additional resources:
Last Updated: 2015-04-15
About the author
View all my tips