Over a million developers have joined DZone.

SQL Prompt to the Rescue With Tab Coloring

DZone's Guide to

SQL Prompt to the Rescue With Tab Coloring

Ever drop a database in the wrong environment? Rollbacks are fun, aren't they? SQL Prompt offers simple, colorful visual cues to tell which environment you're working in.

· Database Zone ·
Free Resource

Find out how Database DevOps helps your team deliver value quicker while keeping your data safe and your organization compliant. Align DevOps for your applications with DevOps for your SQL Server databases to discover the advantages of true Database DevOps, brought to you in partnership with Redgate

When you’re hard at work, it’s all too easy to make a mistake as you rush to get a job done. Say, for example, you have a QA database you need to get rid of. You run a query to drop it and then… oh no! You’ve accidentally run it in Production.

Your day just got even busier. You have to stop whatever you’re doing, restore to a point in time on your Production server and start over. If only there were an easier way to tell which environment you were working in.

Good news: there is!

Tab Coloring With SQL Prompt

There’s already a very helpful feature within SQL Prompt called tab coloring which lets you quickly and easily identify the environment you’re working in within SSMS.

To get started, go to Options in SQL Prompt and find this feature under Tabs> Color:

Add your server or database, and choose the environment from the drop-down menu. We’ve set up some default options, but you can edit the colors and add more if you wish by clicking Edit environments. You can add as many as you like.

As soon as you click OK, you’ll see your open tabs change color to match their environment.

SQL Prompt tab coloring 2You can tell immediately here that you’re in Production because the tab is bright red, and therefore you need to be careful when you run a DROP DATABASE statement.

Tab Coloring for Groups

If you set a tab color for a group, then all servers within that group will be assigned the same color. This is useful if you’re working on multiple groups at once and want to quickly distinguish between their related tabs.

Tab Coloring for Servers

If you want to set a color for an individual server you can do that too. If you’ve already set up a group color, you can overwrite that color for an individual server by setting a new color. This can be helpful if you want to mark all of your Production servers as a different color regardless of group, for example. Remember that if you set a group color after you set your server color, that will change the server color, so be sure to follow this process in the right order.

Tab Coloring for Databases

You can also set different tab colors for individual databases. This won’t change your server or group tab colors when you set these.

We love SQL Prompt tab coloring in SSMS because it gives you that additional reminder to ensure you’re not doing something you may regret on your Production system, plus it helps you organize your tabs to help you work more efficiently.

Want to find out more?

Data Platform MVP Grant Fritchey explains how to use SQL Prompt to color your tabs in the following video:

If you’re not a SQL Prompt user, download a free trial and see how much more productive you can be writing code every day.

Align DevOps for your applications with DevOps for your SQL Server databases to increase speed of delivery and keep data safe. Discover true Database DevOps, brought to you in partnership with Redgate

sql prompt ,environments ,database ,queries ,tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}