Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Append varchar columns from multiple rows?

Status
Not open for further replies.

nacrotek

Programmer
Jul 20, 2005
5
US
Is there a way to concatenate all the varchar values in a result set? I'm looking for an aggregate function that I could use with a group by.

Say I've got the following data.
ID FK Comment
1 1 Some string value
2 1 Some other string value
3 2 Some usefull bit of whit

and I want the following as output:

FK AllComments
1 Some string value Some other string value
2 Some usefull bit of whit


Thanks for any help.
 
There are several ways to handle this. If the number of records per id are less (around 5-6 maximum) then use the max(case...) logic else create a function.

Check [link thread183-1129808] this [/url] thread for details.

Regards,
AA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top