Search in Help for developer site.

Sunday 5 March 2017

select * from Query Shortcut in Sql Server

Get Rid of writing "select * from" again and again to get table data.

 Developers uses to write "select * from tableName" query again and again to get data of any table. Which is the repetitive text in every query and every developer thinks that why am i writing this again and again?. why can't we create a shortcuts for this after all we are smart developers and smart Programmers. Isn't it? 
After reading this article you will thank me because it saves a lot of time for you . Its simple yet Amazing.

Select * from Query Shortcut in Sql Server

Today i am going to share, how to get rid of writing "select * from" again and again to get data from any table.

What if we can create a shortcut to get the data of any table without writing "Select * from", Just select the table name and press the shortcut keys to get data of that table.

The way we do to get the schema of any table, we press "Alt + F1" to get the schema of highlighted table. Likewise we will create a Keyboard shortcut in Sql Server  for getting the data of any table.

Lets start, First open the SSMS and go to Tools->Options, One window shall open then go to Environment->Query Shortcuts

Now you can see one Query Shortcuts grid
So we will be assigning "Ctrl + 3" shortcut for "Select * from " query. Write "select * from " in font of "Ctrl + 3 ".

You can assign to any of the listed Keyboard shortcuts but in this article I will be assigning to "Ctrl+3" because this shortcut is easy to press. I mean not to give any Pain to your fingers.

Follow the Image.


That't it click on Ok button to apply changes.

Now get ready for the Magic
Open a New Query Window and write any table name that exists in the current used database.
Now select the table name and Press "Ctrl + 3" shortcut to fire "Select * from table name" query automatically. Voila here you see the data. Simple yet Amazing shortcut. Isn't it?
Note:- Table name should be selected.



You can see that we have not used the "Select * from " before the table to get its data.

Other Examples:-

1. You can use it with the where clause also 



2. If you want to get top 100 record not all then you have to modify the shortcut to "Select top 100 * from ". now when you press the "Ctrl + 3" keyboard shortcut it will get you only top 100 record.


What do you think?

Write your comments into the Comments section below.


5 comments:

  1. Useful article.

    ReplyDelete
  2. Thanks Durga for reading the article "Select * from shortcut in sql server."

    ReplyDelete
  3. I tried as the way of your article still shortcut key not working

    ReplyDelete
    Replies
    1. It will start working in new window.
      and you have to select the table name first then press control + 3

      Delete