Share via


How to Create Query Shortcuts in SQL Server Management Studio

You can create shortcuts for frequently used queries in Management Studio, some of the shortcuts are predefined, like pressing "Ctrl + 1" will execute "sp_who". You can create shortcuts for your own queries or change the existing shortcuts.

To create a new shortcut, go to Tools > Options > Environment > Keyboard in Management Studio.
For example, you can create a shortcut for:

SELECT  COUNT(*)
FROM    AdventureWorks2008R2.Person.Address

Before you can use the shortcut you will need to restart Management Studio.

To use this shortcut:

  1. Restart Management Studio/Login to an instance,
  2. Press "Ctrl + 3" (or the key you have assigned in your environment)
  3. It will run the specified query and return the results.

You can also generalize the shortcut as below:

For example, create a shortcut for:

SELECT  COUNT(*)


 

To use this shortcut:

  1. Restart Management Studio/Login to an instance,
  2. Type fully qualified name of a table/view, e.g. Database.Schema.Table, (if you are in proper context you can also user Schema.Table or Table)
  3. Highlight the name and press "Ctrl + 3" (or the key you have assigned in your environment)
    4. It will run the specified query and return the results.


See Also