468,544 Members | 1,823 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,544 developers. It's quick & easy.

script to combine multiple rows into a single row

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.

Appreciate your help and time. Thank you in advance
Jul 20 '05 #1
1 9157
li*********@yahoo.com (Valerie) wrote in message news:<f4**************************@posting.google. com>...
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.

Appreciate your help and time. Thank you in advance


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.

Simon
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by mark | last post: by
5 posts views Thread by Antanas | last post: by
2 posts views Thread by Michael | last post: by
1 post views Thread by UniDue | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.