Assign Colors in SQL Server Management Studio Query Windows Based on Environment

By:   |   Comments (4)   |   Related: > SQL Server Management Studio


Problem

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.

Solution

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.

Step 1

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.

Choose properties of a registered server

Step 2

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.

Tick the seeting use custom color

Step 3

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.

Choose color for server connection

Now click on the OK button of the "Edit Server Registration Properties" window to apply the changes.

Step 4

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.

Checking color is set to new query window

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.

Next Steps
  • 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:


sql server categories

sql server webinars

subscribe to mssqltips

sql server tutorials

sql server white papers

next tip



About the author
MSSQLTips author Manvendra Singh Manvendra Singh has over 5 years of experience with SQL Server and has focused on Database Mirroring, Replication, Log Shipping, etc.

This author pledges the content of this article is based on professional experience and not AI generated.

View all my tips



Comments For This Article




Friday, September 29, 2017 - 2:55:27 AM - David Back To Top (66706)

Hi! thanks for this tip, very useful

Just in case anyone has the default Window Layout:

- Menu View -> Registered Servers or CTRL + ALT + G

- In Local Servers Group -> right click and select New Server Registration...

- Add your connection configuration

 

Regards


Friday, April 15, 2016 - 7:33:46 AM - Gillian Back To Top (41236)

 Thank you very much.  This is very useful.  Gillian

 


Monday, April 20, 2015 - 3:30:53 AM - Saurav Vaish Back To Top (36985)

Hey,

This is really cool and helpful when working on differrent environments through CMS. Thanks.


Wednesday, April 15, 2015 - 12:35:06 AM - Steve Sc Back To Top (36939)

I love this feature, Production == Red, Dev == Green, Localhost == Orange, QA = Purple.  A visual cue that lets me know where I'm working.















get free sql tips
agree to terms