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
 General SQL Server Forums
 New to SQL Server Programming
 Obtaining Column values separated by comma

Author  Topic 

srxr9
Starting Member

15 Posts

Posted - 2006-09-26 : 09:55:09
How do I get the values of a column from a table separated by a comma.

For example

Suppose I have a table with column Levels (below), I want the values of the corresponding column separated by a comma, so that I can use this in a different query to pull these values from a different table

Levels
Level1Name
Level1Value
Level2Name
Level2Value

Result should look like
Level1Name, Level1Value, Level2Name, Level2Value


Thanks
Suresh

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-26 : 10:11:52
There are hundreds of examples here at SQLTeam with concatenating functions.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2006-09-26 : 10:16:00
Perhaps you should just ask about what you want as an end result. It sounds like you are doing needless things.

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-09-26 : 10:47:44
Read this
http://sqlteam.com/forums/topic.asp?TOPIC_ID=72555

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-09-26 : 11:17:48
"so that I can use this in a different query"

How are you planning to use this in your other query? I reckon there are better ways to do this can concatenating the Levels - explain your product, not your proposed solution!, and then see what folk here can come up with.

Kristen
Go to Top of Page
   

- Advertisement -