JackW9653
asked on
Multiple Values in SQL table returned in single column separated by commas
Hi Experts,
I have a SQL Server table of short (nvarchar 75) answers filed using a code to group them by. I'm wanting to run a query that will return all answers given for a specific code separated by a comma.
For example:
100 Apple
100 Orange
100 Pear
200 Grape
200 Tangerine
Query returns for group 100:
Apple, Orange, Pear
I've used FOR XML PATH in the past but was hoping to find a different approach. Thanks,
JackW9653
I have a SQL Server table of short (nvarchar 75) answers filed using a code to group them by. I'm wanting to run a query that will return all answers given for a specific code separated by a comma.
For example:
100 Apple
100 Orange
100 Pear
200 Grape
200 Tangerine
Query returns for group 100:
Apple, Orange, Pear
I've used FOR XML PATH in the past but was hoping to find a different approach. Thanks,
JackW9653
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
your are welcome
ASKER
Thanks for your reply. I used COALESCE and was getting extra characters between text and comma, then I added a RTRIM statement and the world was right again.
JackW9653