Shortcut: Using Colors to Avoid Running Scripts Against the Wrong Server

Everyone who's worked with SQL Server for any length of time, has had the experience of executing a T-SQL script, and then noticing, with horror, that they've just executed the script against the wrong server.

You know the feeling. It even happens at Christmas time, just when you were hoping to get away from work for a few days, or when you are the unlucky one who's doing on call work.

Many of these surprises would be avoided if there was something that gave you a visual clue that you were connected to the wrong server.

SQL Server Management Studio (SSMS) has had an option to color code connections to servers for quite a while. The solution isn't perfect and isn't as good as Mladen Prajdić's SSMS Tools Pack:

(If you're keen to pay for an add-in, I do recommend that one)

For many people though, the colorizing provided by SSMS is just enough. And it's easy to use.

When you open a new database connection, you can click Options:

This opens a larger dialog that allows you to specify a color for the connection:

I've chosen Red to warn me that this is a production server.

Then, you'll see the color bar at the bottom of each script window in SSMS:





3 thoughts on “Shortcut: Using Colors to Avoid Running Scripts Against the Wrong Server”

Leave a Reply

Your email address will not be published. Required fields are marked *