Color Coding a Database on All Servers with SQL Prompt

SQL Prompt has some nice color coding features, but sometimes I want a database to keep the same color, regardless of instance. I don’t know that I’d recommend this, but since I work in demo environments across versions, this is a handy trick for me.

In the SQL Prompt menu, there is an options item.

2020-07-11 10_39_15-

Clicking this brings up a dialog with a number of sections along the left and details on the right. Near the bottom is the color menu.

2020-07-11 10_39_26-SQL Prompt – Options

When I decide to color code a database, I click “add” and I get this view. The cursor defaults to the Server/Group edit box, and I’ve typically entered a server name here.

2020-07-11 10_39_39-SQL Prompt – Options

However, I can skip this and just enter a database.

2020-07-11 10_39_51-SQL Prompt – Options

In this configuration, every time I open a query window to a database called SimpleTalk_1_Dev, no matter which instance, it will be colored purple.

I can see this when connecting to my default local instance.

2020-07-11 10_40_01-SQLQuery2.sql - ARISTOTLE.SimpleTalk_1_Dev (ARISTOTLE_Steve (52))_ - Microsoft S

I also test things on a v14 (SQL 2017) instance, and if I connect there, I see the same thing.

2020-07-11 10_41_08-SQLQuery6.sql - ARISTOTLE_SQL2017.SimpleTalk_1_Dev (ARISTOTLE_Steve (60)) - Micr

In some sense, this is an edge case. I demo similar things across instances and versions, and it’s nice to keep colors simple rather than entering dozens of instance names. However, it’s not something many people do, as they often use the same database name on different instances. That’s a more common scenario.

That’s supported as well. Notice here I’ve entered just a server with no database.

2020-07-11 10_47_12-SQL Prompt – Options

Now every database I connect to on this instance will be colored green. Note that the purple still overrides because it is specific to a database. The third tab below is connected to the SimpleTalk_1_Dev database.

2020-07-11 10_47_19-SQLQuery6.sql - ARISTOTLE_SQL2017.SimpleTalk_1_Dev (ARISTOTLE_Steve (60)) - Micr

SQL Prompt has some amazing features, but color coding is one that helps me keep track of which databases and instances I’m connected to in a query window. If you‘ve never configured this, give it a try.

If you’ve never tried SQL Prompt, it’s incredible. Download an eval today and see what you think.

About way0utwest

Editor, SQLServerCentral
This entry was posted in Blog and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.