Colour coded SQL Server 2008 sessions

Microsoft SQL Server 2008 has a limited capability to provide a visible alert if you are connected to a production server.

It does this by changing the colour of the notification bar in the SQL Server Management Console, which can be a life saver if you have numerous SQL Server instances that you work with,  or have production access on some instances and not others.

By default all connections look the same.

By default all connections look the same.

The implementation isn’t fool proof, it only works if you create a new query from the Registered Servers menu rather than clicking the New Query button. Hopefully Microsoft will get this right with a future patch or release, but for it now it relies on the user to retrain themselves to create query sessions via a right click on the Registered Servers pane.

To set up the colour coding follow these steps:

(1) From the View menu choose the Registered Servers item. A new window pane should appear on the left of the Management Console window.

(2) Register the details of the instance you are wanting to connect to by right clicking on the folder you want to include the server registration under, e.g. Local Server Groups, and choose New Server Registration.

(2a) Alternatively if you’re wanting to modify the registration of an already registered instance right click on the registered instance name instead and then choose Properties.

(3) Enter the details of the instance to be registered in the General tab.

(4) Click on the Connection Properties tab and tick the Use custom color box. Push the Select button to choose the colour you wish the notification bar to be colour coded with. Choose the colour and click OK.

Choose custom colour for notification bar alerts

Choose custom colour for notification bar alerts

(5) Click Save to persist the instance registration.

(6) Now right click on the newly registered instance and choose New Query. The query session that opens up in the right hand pane of the window should display the notification bar coloured with the shade you selected during the registration process.

Colour coded notification bar.

Colour coded notification bar.

Once you have retrained yourself to use the Registered Servers pane to launch new query sessions you will have no excuse for accidentally running code in a production environment!

Comments are closed.