A simple but effective setting in SQL Server Management Studio is using custom colours to identify which server you are about to execute a query on. It’s simple to setup but not everyone who uses SSMS is aware of it so I thought I’d quickly run through the steps here.
Open up SSMS, go to View > Registered Servers
So I’ve got different groups for Staging, Production, Corporate etc. If you haven’t got these setup it’s pretty easy. Right click on Local Server Groups and pick New Server Group. Enter in a group new and hit OK. Then right click on your new group and select New Server Registration:-
Fill out the details and then hit the top tab Connection Properties:-
The custom colour option will allow you to set whatever colour you want when you use that registered server to open a T-SQL window. Typically I use red for production, orange for staging, blue for development and, green for my local instances.
It’s a simple enough setting but it’s stopped my from making god knows how many mistakes!
It should be noted that adding the color via Registered Servers isn’t the only way. You can also assign a color in the normal Connect To Server dialog box, then Options button, then Connection Properties tab, and you’ll find the same “Use custom color” checkbox and color picker as seen in the Registered Servers method.