Like most data professionals, my day is pretty busy. Because of this I really like shortcuts. In this post, I’ll talk about a series of shortcuts I use every day that don’t seem to be very well known in the community. In fact, when I’m giving a presentation I often use some of these shortcuts and perhaps the number one question I get from the audience when I do is, “wait…how did you do that?”
The feature I’m talking about is called “Query Shortcuts”. This works for SSMS and I hope it will transfer to Azure Data Studio, but I haven’t tried it myself yet. To view the settings click on the tools menu and select options. From there browse through Environment, Keyboard, and finally, Query Shortcuts. Your screen should look something like this.
These 3 default values cannot be changed. Let’s see how they work by testing the Alt+F1 shortcut for sp_help. Close out of this window for a moment and open a new SSMS query window. Press Alt+F1. This will execute sp_help. The results, however, aren’t especially useful. What is much more interesting is what happens when you first highlight some text. When the shortcut is executed, any text that is highlighted will be sent as a parameter to the procedure listed.
In the screen screenshot below I connected to MSDB, typed in sysjobs (a table name), highlighted it, and then pressed Alt+F1. Now I’m looking at all kind of useful information about the table including column names and data types, indexes, and foreign keys.
This example shows a table name, but you can also select code object names to get parameter listings.
I use this shortcut many times every single day.
What about those other query shortcut options? I have a series of shortcuts that I like to use. My current listing is below. Once you get used to having these shortcuts it’s impossible to go back!