Learn more about SQL Server tools


Tutorials          DBA          Dev          BI          Career          Categories          Events          Whitepapers          Today's Tip          Join

Tutorials      DBA      Dev      BI      Categories      Events

DBA    Dev    BI    Categories


Assign shortcuts to commands in SQL Server Management Studio

By:   |   Read Comments (5)   |   Related Tips: 1 | 2 | 3 | More > SQL Server Management Studio

The SQL Server management tools offer a lot of hidden features, but finding all of these features is sometimes done by accident or by necessity to get a particular job done.  One particular feature that would be helpful is to assign shortcuts for particular stored procedures that you run quite frequently.  By default SQL Server offers default shortcuts such as Alt+F1 (sp_help), Ctrl+1 (sp_who) and Ctrl+2 (sp_lock).  How can you assign your own frequently used stored procedures to shortcut keys?

In the query tool you have the ability to assign keyboard shortcuts for stored procedures that you run frequently.  By default SQL Server assigns some of the most common tasks as such sp_help, sp_who and sp_lock to certain key combinations.  But in addition to these 3 predefined keyboard shortcuts SQL Server also offers you the ability to assign some of your own favorite stored procedures.

SQL 2005
To access the screen below, open a query window and select from the menu Tools -> Options and then select Keyboard under the Environment node.


SQL 2000
To access the screen below, open query analyzer and select from the menu Tools -> Customize...


How to assign a key
At this point you just need to enter the stored procedure that you want to assign to the keyboard shortcut.  By default SQL Server will follow the same rules for finding the stored procedure as when using the query windows. If the stored procedure is not found it will give you an error stating that the stored procedure could not be found 

You can also specify the database where the stored procedure exists such as:



Here is an example where these two stored procedures have been assigned to a shortcut key.  To run these you just need to issue the correct keyboard combination such as Ctrl+3 or Ctrl+4.

Next Steps

Last Update:

About the author

More SQL Server Solutions

Post a comment or let the author know this tip helped.

All comments are reviewed, so stay on subject or we may delete your comment. Note: your email address is not published. Required fields are marked with an asterisk (*).

*Name    *Email    Notify for updates 

Get free SQL tips:

*Enter Code refresh code     

Tuesday, May 14, 2013 - 11:41:52 AM - Greg Robidoux Back To Top

@Steve - thanks for the feedback. 

What are you looking at trying to do?

Tuesday, May 14, 2013 - 11:40:02 AM - Steve Back To Top

One criticism: this should not be called 'Assign shortcuts to commands...', it should be called 'Assign shortcuts to stored procedures...'

I keep tripping over this page thinking it has what I'm really looking for (shortcuts to commands!).

Thursday, December 20, 2012 - 12:48:33 AM - Abrar Back To Top

Ellen, we have "query.custom?" tags for assign shortcut for custom queries...

but the problem on my end is that ... how can assign the tags "query.custom?" the value which they will execute?

Kindly share your favor for this issue?

Thank you!

Monday, December 03, 2012 - 12:20:05 PM - CK Back To Top

Ellen, it is basically the same. Tools|Options|Keyboard|Query Shortcut. Just one more click will make it.

Tuesday, April 17, 2012 - 1:01:45 PM - Ellen Back To Top

How can you do this in SQL 2012?


Learn more about SQL Server tools