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”
There is also the "Color query tabs by environment" feature in the free add-on ApexSql Complete:
Very useful and I wish they would apply the color on the tab as well.
Very useful and I wish they would apply the color on tab as well.