Google Analytics Alternative

Search This Blog

Sunday, March 4, 2012

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.
  1. Go to SSMS, Open a new query window, Type SELECT followed by a space
  2. Go to Object Explorer
  3. 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.
  4. 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.
  5. Remove the unwanted columns
  6. 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.

No comments: