How to Save Yourself From Yourself

Have you ever wished there was some sort of magic “undo” button for something that you just did? Maybe you didn’t really mean to delete all 10 million records out of your table. You just forgot a little thing called a constraint. Such was the case with one of my co-workers recently. He accidentally deleted all of the tables out of the database. On the bright side though, it did give us the ability to test our disaster recovery plan!

To make sure that you don’t have to unwillingly test your disaster recovery plan, there is one easy setting to change in SSMS that will (hopefully) prevent you from making such a mistake.

A co-worker (other than the one who deleted the tables inadvertently) showed this feature of SSMS one day in a weekly code review that we have.

SSMS provides you information in the status bar regarding the server to which you are currently connected. The only bad thing about this is that no matter what server you connect to, there is no real POP of anything to differentiate between environments. You have to physically look down and see what server you are connected to. See the picture below:

Normal

In my job, I connect to Localhost, a Sandbox environment, and a QA environment. It would be nice to have the ability to, at a quick glance (ideally out of peripheral vision), be able to tell to which server I’m currently connected. To accomplish this, follow the steps below.

  • In the Object Explorer pane, click Connect —> Database Engine
  • Click Options. The Connection Properties tab is now selected.
  • Check Use custom color, then click Select to choose your custom color.
    • As a rule of thumb, I use Green for Localhost and Red for anything else (Green = Good; Red = CAREFUL!!)

Options

Now, connect to a new instance of your SQL Server, and open a new query window. Notice the status bar at the bottom of the screen:

Green

And, the nice thing is that these preferences are saved until you change them, even if SQL Management Studio is closed. So, as has been famously coined before, “Set it and forget it!!” Hopefully this little trick will save you from yourself. I know that it’s saved me a time or two!

This entry was posted in Uncategorized and tagged . Bookmark the permalink.

Comments are closed.