Over a million developers have joined DZone.

Keyboard Query Shortcuts in SQL Server Management Studio

Keyboard shortcuts are incredibly important for the life of the productive developer, and not just for IDEs- If you're using SQL Server Management Studio then this article will help you get up to speed.

· Database Zone

Build fast, scale big with MongoDB Atlas, a hosted service for the leading NoSQL database. Try it now! Brought to you in partnership with MongoDB.

In this article, we are going to see some shortcuts that may be useful to you when you work with SQL Server Management Studio. You can always use some custom queries as query shortcuts in SSMS, too. Here I am going to show some of the most used the queries shortcuts. I hope you will like this.

Background

If you are a dot net developer or if you are working with any Microsoft technologies, you must have some experience in working with SQL and SQL Server Management Studio. But, as a developer, we always try to achieve the things in a simple manner. Right? This is where we are going for keyboard shortcuts. We do have an option to set and use the keyboard shortcuts in SSMS too. I will explain those.

Keyboard Query Shortcuts in SSMS

First of all, let me tell you an example of where we can use the keyboard shortcuts. We know how to create stored procedures, right? These procedures are created in a folder called ‘Stored Procedures’ under Programmability. Now, let's assume that I have a stored procedure with the name as usp_Get_SalesOrderDetail. Now, if you need to see the queries we have written in that stored procedure, what will you do? You have two options:

  • Right click on the stored procedure and click on modify
  • Use the sp_helptext as sp_helptext usp_Get_SalesOrderDetail

Now, my question is, in this scenario, whenever you need to see the stored procedure you need to type sp_helptext right? How can we overcome this situation? Here we can set the keyboard shortcuts.

Setting the Keyboard Shortcuts

Go to Tools -> Options.

Tools_OptionsTools_Options

Go to Environment -> Keyboard -> Query Shortcuts.

Image title

Environment_Keyboard_Query_Shortcuts_

On the right side, you can see some shortcuts which are by default in SSMS. Now, if you need to add a new one, just click on any column under Stored Procedure column.

Adding_a_new_keyboard_shortcutAdding_a_new_keyboard_shortcut

Click OK. Now please go to a query window and select the stored procedure then press CTRL+3, it will show the stored procedure.

Image title

sp_helptext_Results_

Now, if you need to select all the records from a table when you select the table and press CTRL+5 (You can select any key). You can make the shortcut as follows.

Selct_Query_As_Keyboard_Shortcut 

Selct_Query_As_Keyboard_Shortcut

Now, please go ahead and select the table name from the query window and press CTRL+4 (the key we selected). I hope you got the result as expected. Have a happy coding!

Conclusion

Did I miss anything that you may think would help? Did you find this post as useful? I hope you liked the article. Please share your valuable suggestions and feedback in the comments.

Your Turn. What Do You Think?

A blog isn’t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, or the Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.

Now it's easier than ever to get started with MongoDB, the database that allows startups and enterprises alike to rapidly build planet-scale apps. Introducing MongoDB Atlas, the official hosted service for the database on AWS. Try it now! Brought to you in partnership with MongoDB.

Topics:
sql server ,productivity

Published at DZone with permission of Sibeesh Venu, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}