There comes a time in every man’s life when he must cross the boundaries of common sense, when he must go against society’s norms to accomplish something great, when he must… run sql code in Sql Server Management Studio (SSMS) directly against a production server. We all do it. We all have valid reasons to do it. In many cases it’s necessary. But it’s also dangerous.
If you have elevated permissions on the sql server, there’s a chance you could accidentally run something in SSMS and make an unwanted change to a production environment. Even if you only have read permission to the server, you could run a query that ends up blocking some other more important operation. Or maybe your long query consumes enough system resources that it slows down your business critical app to an unacceptable level. In any case, we must be careful and additional considerations must be taken into account when dealing with the various production and development environments we work in.
If you’re like me, you typically have several instances of SSMS open at once. In each of those SSMS windows, you probably have several query tabs open. Each of those queries may be connected to various development, test, staging, or production environments. That’s a lot to keep track of. And as you’re working, switching between query tabs and SSMS windows, it can be easy to forget what you’re connected to.
To keep better track of what SQL Server I’m connected to, I use the color feature of the SSMS status bar. When you connect to a server, there’s an options button:
You click the options button to get into the advanced SSMS connection options panel:
In the advanced connection options panel, you can choose a custom color for your connection. This color is applied to your status bar, and it sticks so every time you connect to that server is uses the same color. This color option is also available in registered servers, if you set those up on your local system or on a centrally managed server.
Having colors set for each of your servers can make it easy to tell at a glance in SSMS whether for example you are connected to production vs test. I typically set my production servers to bright red, and you really do notice when a big red status bar is staring you in the face. For my other development environments I try to set colors in various levels. My less secure playaround servers get set to calm soothing colors and then I work up to bolder and brighter colors as the environment gets more important.
Sound like a good idea? Give it a go and let me know if coloring the SSMS status bar is as helpful for you in your development activities as it has been for me.