Assign shortcuts to commands in SQL Server Management Studio

By:   |   Updated: 2007-07-17   |   Comments (5)   |   Related: 1 | 2 | 3 | 4 | > SQL Server Management Studio Shortcuts


Problem

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?

Solution

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.

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

ssms shortcut keys

How to assign a shortcut 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:

master.dbo.sp_who2 
AdventureWorks.HumanResources.uspGetEmployeeList

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.

ssms shortcut keys
Next Steps


sql server categories

sql server webinars

subscribe to mssqltips

sql server tutorials

sql server white papers

next tip



About the author
MSSQLTips author Greg Robidoux Greg Robidoux is the President and founder of Edgewood Solutions, a technology services company delivering services and solutions for Microsoft SQL Server. He is also one of the co-founders of MSSQLTips.com. Greg has been working with SQL Server since 1999, has authored numerous database-related articles, and delivered several presentations related to SQL Server. Before SQL Server, he worked on many data platforms such as DB2, Oracle, Sybase, and Informix.

This author pledges the content of this article is based on professional experience and not AI generated.

View all my tips


Article Last Updated: 2007-07-17

Comments For This Article




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

@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 (23945)

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 (21043)

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 3, 2012 - 12:20:05 PM - CK Back To Top (20718)

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 (16977)

How can you do this in SQL 2012?

Thanks.















get free sql tips
agree to terms