Groups | Blog | Home
all groups > sql server (alternate) > august 2003 >

sql server (alternate) : script to combine multiple rows into a single row



lie_valerie NO[at]SPAM yahoo.com
8/14/2003 4:05:11 PM
Hi everyone,

I really appreciate if anyone could help me with this tricky problem
that I'm having. I'm looking for a sample script to combine data in
multiple rows into one row. I'm using sqlserver. This is how data is
stored in the table.

ID Color
111 Blue
111 Yellow
111 Pink
111 Green

This is the result that I would like to have.

ID Color
111 Blue, Yellow, Pink, Green

There is no definite number of colors per ID. I have to use ID to
group these colors into one row. Therefore, ID becomes a unique key
in the table.

sql NO[at]SPAM hayes.ch
8/15/2003 12:53:22 AM
[quoted text, click to view]

The short answer is that you should consider doing this in your client
application. For a longer answer, have a look at the thread "newbie
sql query question" in this group from a day or two ago.

AddThis Social Bookmark Button