I work with all kinds of SQL Server instances. All of them are one of three possible types:
Many of my scripts have a quick query at the top to get the server name (@@servername). I use this to double check the server instance I’m on. More specifically, I use this to make sure I’m NOT on a production server (when not deploying production changes).
Andy Menon, a co-worker and all around genius, showed me how to change the color of the status bar depending on what server SSMS is connected to. He suggested changing the color based on the type of the server connection, such as:
- Development – GREEN (who cares, hack away, you’ve got the green light)
- Test – YELLOW (caution, you may end up jacking up someone’s code)
- Production – RED (STOP… do you know you are on a prod server?)
By making a simple change in the connection box for all of your servers your status bars can look like this:
There’s no new science here, but if it can spare me just one time from unintentionally executing code on a production machine, it is well worth the time to set this up. Plus, I always know where I am! What a concept…
Here’s a quick guide on how to do it:
- In SSMS open a new database connection in Object Explorer.
- Click on “Options”:
- Click on Connection Properties
- 4. Click Use custom color.
- 5. Pick your color.
- 6. OK… Connect.
Here’s the official Microsoft link on how to do this in Object Explorer (and Central Management Server).
Stay curious, keep learning…