Quickest way to SELECT All Columns from a Table
Suppose you have a huge table which has say 30-40 columns and you want to select all of them or most of them say around 30 columns. It is a tedious job to type each of the column names. Here is a quick way to get a comma separated list of all the columns with minimal effort.
- Go to SSMS, Open a new query window, Type SELECT followed by a space
- Go to Object Explorer
- Expand the databases node, expand the user database which contains your table, expand the Tables folder, Expand the Table from which you need to selec the Columns/Data.
- Click on "Columns" folder, hold it, and drag it on to the Query Surface after the "SELECT " (Step 1). This place all the columns on to the query surface in a comma separated fashion.
- Remove the unwanted columns
- Now type in " FROM TableName" at the end of the column list (Outcome of Step 4 & 5) and do the necessary formatting.
It is as simple as that ! This can save a lot of effort required to manually type in the Column Names.
Comments