Site icon Andy M Mallon – AM²

SSMS Query Shortcuts

Shortcuts & tips from an Impatient DBA #4

This series of short posts will demonstrate some lesser-known features, keyboard shortcuts, and other tips that make my day as a DBA more productive. None of these are groundbreaking super-secret features–they are the little things that I do as part of my daily work that make me more efficient.

SSMS Query Shortcuts

The first time I saw someone use this feature, I had a “How the **** did you do that?” moment. I was watching my coworker over her shoulder, she highlighted a table name hit something on her keyboard, and suddenly had the sp_help results for that table. It seemed like black magic.

Turns out, it’s not black magic. It’s just a pretty cool feature I’d never noticed in the SSMS options.
Under Environment–>Keyboard–>Query Shortcuts you can have a total of 12 of these query shortcuts. Simply specify a stored procedure name (Ideally one that takes a single parameter). Then, back in your query window highlight text, and that text will get passed to the stored procedure as a parameter.

There are a couple catches.
1) You can’t customize the actual keystrokes. Redmond tells you what shortcut keystrokes to use for this feature and that’s it.
2) Three of the shortcuts are predefined & non-editable. This means you only have 9 custom query shortcuts to define yourself. I’ve never actually used every spot, so I don’t think this is too limiting.
3) If you edit your query shortcuts, any open query windows won’t notice the change–you’ll have to open a new query window to use your edited shortcuts. This is mostly a one-time pain point, but notable if you’re going to mess around & experiment with the feature.

One more tip:

The column header says “Stored Procedure” but that’s not strictly accurate. You can actually make a shortcut for something like “SELECT TOP 10 * FROM “. Highlight  a table name, type your shortcut keys (CTRL+3 in my example below), and poof you get your query results. I use this all the time when I’m debugging code on an unfamiliar table or database. Sometimes sp_help just isn’t helpful enough–I need to see some sample data, too.

 

Exit mobile version