Query shortcuts in SQL Server Management Studio

Tired of typing out the same queries day after day? Well query shortcuts in SSMS are for you!

Following on from my last post Changing connection colours in SSMS I thought I’d write another quick about this cool but also often unused feature in SSMS.

These shortcuts allow you to run pre-determined queries by assigning a hot key within SSMS. To do this in SSMS go to Tools > Options > Environment > Keyboard


From there you can set the query to the hot key you want to use. Nice and easy!

In nearly all of the instances of SQL Server that I look after, I’ve installed Adam Machanic’s excellent sp_whoisactive. By adding the above shortcut into SSMS I can run it quickly and easily in any instance that I’ve connected to. It’s really handy and I’d definitely recommend you install it and set a query shortcut up for it.

Thanks for reading!

Changing connection colours in SQL Server Management Studio

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!