Shortcut: Set query shortcuts for favorite stored procedures in SSMS

In an earlier post, I mentioned how useful the F1 key is. On its own, it provides syntax help, but when you highlight an object and hit Alt-F1, you get to see metadata about the object.

Under the covers, this just runs the sp_help stored procedure. Alt-F1 has been mapped to that.

You can see where this is configured, change it if required, and/or configure other procedures as well.

In Tools, Options, Environment, Keyboard, then Query Shortcuts, you can see this:

Here we can see how the Alt-F1 command is configured. By default, only three shortcuts are configured. It's easy to configure another one for your own use.

4 thoughts on “Shortcut: Set query shortcuts for favorite stored procedures in SSMS”

  1. Can you provide more details and an example? I can't seem to get this to work.

    I created a stored procedure "sp_Foo" in the master database. I can call it and it works.

    I then type "sp_Foo" into the Ctrl+3 slot.

    I go to a new query window in whatever database I'm working in, and hit Ctrl+3 and nothing happens.

    The other pre-defined short-cuts work just fine. What am I missing?

    1. Sure. One quick question though. Given you seem to be trying to create a new system stored procedure, have you marked it as a system object? Ie: sp_MS_marksystemobject You need that as well as an sp_ name prefix for that.

      1. This is new info for me… in the past I've had success just naming it "sp_" and sticking it in master, so that SQL Server looks there for the stored procedure first, instead of in the current database. I figured this was a requirement to legitimately use this feature since the alternative would be to have to install the stored procedure on every database on the server, in order for the hot-key to work reliably no matter what database you were currently "in". So no, I've never marked it as a system object… is this a requirement of this hot-key thing? I'm still confused and feel like I'm missing something.

        1. The hot key thing is unrelated to the system stored procedure aspect. It just maps a key to a procedure. But you need it to be a system stored procedure to make it run from wherever you happen to be. To do that, you place it in master, it must be in the dbo schema, it must have an sp_ prefix, and you mark it with sp_MS_marksystemobject to flag it as a system object. Here's a link to an example: https://www.mssqltips.com/sqlservertip/1612/creating-your-own-sql-server-system-stored-procedures/

Leave a Reply

Your email address will not be published. Required fields are marked *