Creating T-SQL Query Shortcuts in SQL Server Management Studio(SSMS)

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
Fig. 1 Choose Options from Tools
  • Under Environment, choose Keyboard and select Query Shortcuts
Fig. 2 Query Shorts in SSMS

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.

Fig. 3 Query Shortcut added

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

Fig. 4 Demo

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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Website Built with WordPress.com.

Up ↑

%d bloggers like this: