Learn more about SQL Server tools


Latest from MSSQLTips

Assign shortcuts to commands in SQL Server Management Studio

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

> > Free Whitepaper - Resolving the Database Performance Blame Game

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: 7/17/2007

About the author
MSSQLTips author Greg Robidoux
Greg Robidoux is the President of Edgewood Solutions and a co-founder of MSSQLTips.com.

View all my tips

print tip Print  
Become a paid author

join MSSQLTips for free SQL Server tips     

Learn more about SQL Server tools

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

       All comments are reviewed, so stay on subject or we may delete your comment.

*Name   *Email Notify for updates

       Note: your email address is not published. Required fields are marked with an asterisk (*)

Get free SQL tips:

*Enter Code refresh code     

Tuesday, May 14, 2013 - 11:41:52 AM - Greg Robidoux Read The Tip

@Steve - thanks for the feedback. 

What are you looking at trying to do?

Tuesday, May 14, 2013 - 11:40:02 AM - Steve Read The Tip

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 Read The Tip

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 Read The Tip

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 Read The Tip

How can you do this in SQL 2012?


Sponsor Information



Get Free SQL Tips










BI Professionals


Q and A

Today's Tip







Tip Categories

Search By TipID



First Timer?


Free T-shirt



User Groups

Author of the Year

More Info








Copyright (c) 2006-2015 Edgewood Solutions, LLC All rights reserved
Some names and products listed are the registered trademarks of their respective owners.