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:
- Restart Management Studio/Login to an instance,
- Press "Ctrl + 3" (or the key you have assigned in your environment)
- 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:
- Restart Management Studio/Login to an instance,
- 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)
- 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.