By: Matt Wollner
Senior BI Consultant at Key2 Consulting
Keyboard shortcuts play an important role in increasing the productivity of any development environment. There are myriad shortcuts that are highly beneficial in SQL Server Management Studio (SSMS), and SSMS also allows you to easily add your own keyboard shortcuts.
Using a keyboard shortcut in SSMS will add the given code before any SQL that you highlight. Two shortcuts that I add to my SSMS instance are:
SELECT TOP 1000 * FROM
SELECT COUNT(*) FROM
This is simple to set up in SSMS 2005/2008.
- Tools -> Options
- Environment -> Keyboard
- Add the following shortcuts to the Query Shortcuts. I set the SELECT* as the Ctrl+5 because execute is F5, so it is easy to remember. Make sure you include a space after the FROM.
- Ctrl+5: SELECT TOP 1000(*) FROM
- Ctrl+6: SELECT COUNT(*) FROM
- After you apply the changes, make sure you open a new session.
Now that the shortcuts have been setup, all I need to do to get a SELECT TOP 1000 (*) FROM a table is highlight the table name and hit Ctrl+5.
You can also highlight additional code. The shortcut will just append the shortcut text before the highlighted code. In the example below I select the table, an inner join, and a where clause and hit Ctrl+5
Here are some additional shortcuts in SSMS that I find very handy:
Ctrl+R: Hide Show Result Pain
ATL+Q – C – H: Change Connection. (Open Query Window – Connection – Change Connection…)
Ctrl+Shift+R: Refresh the IntelliSense Cache