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 2000 Forums
 SQL Server Development (2000)
 Concatenate multiple values?

Author  Topic 

Blastrix
Posting Yak Master

208 Posts

Posted - 2004-06-30 : 17:59:53
I know how to use COALESCE with a variable to assemble a delimited string for one item, but I'm trying to figure out how to do it for multiple rows.

CREATE TABLE ItemFeatures (
ItemID int,
Feature varchar(50)
)

INSERT INTO ItemFeatures VALUES (1, 'red')
INSERT INTO ItemFeatures VALUES (1, 'large')
INSERT INTO ItemFeatures VALUES (1, 'striped')
INSERT INTO ItemFeatures VALUES (2, 'blue')
INSERT INTO ItemFeatures VALUES (2, 'small')
INSERT INTO ItemFeatures VALUES (2, 'spotted')

So I would be looking for results like this:

Item Features
1 red, large, striped
2 blue, small, spotted

I don't need to resort to a cursor or loop or some such, do I?

Thanks,
Steve

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-06-30 : 18:24:18
http://www.sqlteam.com/item.asp?ItemID=11021

Tara
Go to Top of Page
   

- Advertisement -