Introduction
Using keyboard shortcuts, it saves time, isn’t it?. SQL Server Management Studio is also not an exception !!!. We can add our own custom keyboard shortcuts, that too for T-SQL query. Really cool !!!! How many of you know about this feature???. Do not worry if you did not know this before. Now you are in the right place. In this article we will discuss about adding custom keyboard shortcuts for T-SQL Statements.
Add T-SQL Query as Keyboard Shortcuts
Support when we are working in SQL Server and one T-SQL Statement is frequently used almost everyday, instead of keeping it as a .sql file, we can add it as a shortcut key. So whenever required just press those keys. To add T-SQL queries as keyboard shortcuts in SSMS,
- Click Tools, and choose Options

- Under Environment, choose Keyboard and select Query Shortcuts

If we look into the Query Shortcuts section, the keyboard shortcuts ALT+F1, CTRL+1,CTRL+2 are already added by the SQL Server. So as a user we cannot modify these shortcuts.
Now lets add our own Query Shortcuts, as for an example, let’s add Query Shortcuts for CTRL+F1, and I have added SELECT * FROM (include a space after FROM) as a T-SQL query. Once added click OK button.

Basically this shortcut will select all from the table whatever we specify. That is hereafter we no need no write the query as,
SELECT * FROM TableName
Instead, we have to mention the table name and select it before applying the query shortcut. Once the keys are pressed, all the columns in the table will be returned in the result set. In our case, highlight the table, and click CTRL+F1

Likewise we can add our own query shorts and increase for productivity and eliminate the frequently writing statement.
Conclusion
In this article, we have discussed about the query shortcuts in SSMS. I hope you all found this article much useful. Please share your feedbacks in the comment sections. We will see more productivity tips in our upcoming articles.
Leave a Reply