Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Select data from table and column names as output

Author  Topic 

jbrown7232
Starting Member

22 Posts

Posted - 2010-06-30 : 13:52:55
Hello,

I have a table called Basic with 2 columns (Names and email).

How can query the table for all the data and have the column names listed to identify each column of data?

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2010-06-30 : 14:11:04
Yoicks, you need to sleep less in class!

Select names,email from Basic


Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-06-30 : 15:24:04
I'm guessing they want it in the result set

Want it a quote idenitifed, comma delimited?


SELECT '"'+'Names'+'","'+'Email'+'"'
UNION ALL
SELECT '"'+Names+'","'+Email+'"'
FROM Basic




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -