Getting Started with Adobe After Effects - Part 6: Motion Blur
A collection of quick technology learning tips from what people around you learn every day

Replacing "Select * " to "Select Column list"

Jul 8 2012 12:00AM by abhIShek BandI   

Hi,

We know the hint , how to get all the column names of a table into query window using drag and drop of Columns Folder under TableName.

SSMS Hint

Today , i learned another method to do the same,

Select the query and right click on it , select Design Query on Editor option, and click on ok button.

SSMS Hint

Read More..   [32134 clicks]

Published under: SQL Server Tips ·  ·  ·  · 


abhIShek BandI
104 · 2% · 503
16
 
4
 
12
 
0
Incorrect
 
0
Interesting
 



Submit

11  Comments  

  • I did not know about that first way: drag/drop the column folder. Neat and thanx!

    commented on Jul 9 2012 10:08AM
    Flashspot
    554 · 0% · 66
  • Good One. I was aware of the first approach as I blogged about it here a while ago, but the second approach is a refresher for me :)

    commented on Jul 10 2012 6:50AM
    Dattatrey Sindol (Datta)
    43 · 4% · 1333
  • I always use the 2nd approach on large tables where I need a large subset of random columns, it is easier to untick the columns not required and copy the query. :)

    commented on Jul 11 2012 1:57AM
    denzilwhite
    1720 · 0% · 11
  • Nice. Thanks

    commented on Jul 11 2012 4:02AM
    Lokesh
    1823 · 0% · 10
  • Great tips, both of them, but both are more complicated than necessary IMHO.
    If your primary goal is to simply expand the column list of a table into a query without manually typing it all in, try this:

    In SSMS 2k5:

    1. right click the table in Object Explorer
    2. Script Table as
    3. SELECT To
    4. "New Query Window" or "Clipboard"

    Easy.

    commented on Jul 12 2012 10:22AM
    Lars007
    1720 · 0% · 11
  • If you have 150 columns and you need say a random 72 of them in a specified order you can just tick the boxes for each column in the order you need in query builder. Using script SELECT TO would leave you with a massive cut and paste job.

    commented on Jul 12 2012 10:45AM
    denzilwhite
    1720 · 0% · 11
  • Good point denzilwhite. I guess it all comes down to personal preference. I would rather do the text edit than a checkbox select and scroll, so whatever floats your boat. Using your example of 150 columns, the columns that are to be excluded can be commented out and the script saved. If you miss one column using the checkbox method, you need to start the process over again to find the missing column. That's just my personal preference, plus, I don't mind typing, so perhaps I'm the exception ;-)

    commented on Jul 12 2012 1:15PM
    Lars007
    1720 · 0% · 11
  • If you miss one column you just type or drag it in :) I did not say to leave it in query builder, just to use it as a base for your query and then paste it back into query analyser.

    I am definitely all for typing, as the more complex the query gets, the less likely query builder can support it. Or should I say display it graphically.

    Anyway I guess this is now a conversation outside this discussion.

    commented on Jul 12 2012 1:33PM
    denzilwhite
    1720 · 0% · 11
  • thanks for the post. really very helpful .

    commented on Jul 13 2012 10:25AM
    Nirav
    37 · 5% · 1593
  • I just script the table as a SELECT from the table context menu. This gets me the SELECT in the format I like too.

    Also, when dragging the columns in these are not wrapped in square braces so any column names that would need wrapping will need this to be done manually afterwards. Scripting the SELECT wraps the columns for you.

    commented on Jul 16 2012 6:48AM
    Chris Jenkins
    989 · 0% · 26
  • This tip not only for list the columns for single table, we can get the columns for CTE and Sub Query too.

    Fox example, Our CTE or SubQuery returning multiple columns and we need to apply some calculations or conversions on particular columns,then definitely we need to type all the column names then we need to apply the changes on particular column.

    But using this we can select the query and follow the TIP to get the list of columns.

    Sample Query:

    --EX:1
    WITH CTE AS (
        SELECT SP.name ,  SC.text 
        FROM sysCOMMENTS SC 
        	 INNER JOIN sys.procedures SP ON SC.id = SP.object_id 
    )
    SELECT * FROM CTE 
    
    --EX:2
    SELECT * 
    FROM (
        	SELECT SP.name ,  SC.text 
        	FROM sysCOMMENTS SC 
        		 INNER JOIN sys.procedures SP ON SC.id = SP.object_id 
         ) AS A
    
    commented on Jul 17 2012 12:25AM
    abhIShek BandI
    104 · 2% · 503

Your Comment


Sign Up or Login to post a comment.

"Replacing "Select * " to "Select Column list"" rated 5 out of 5 by 16 readers
Replacing "Select * " to "Select Column list" , 5.0 out of 5 based on 16 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]