February 22, 2011 at 4:44 am
Hi,
I have a result set containing several fields, one of which 'Comment' is a varchar field. I would like to group by all the other fields and concatenate all the 'comment' values into just one string. Can anyone advise how I might do this? - So rather than aggregating the field, I just want the values concatenating to each other (with possible the addition of a 'space' delimiter).
I've not posted any DDL code, as thought the answer could possible be given in principle.
Any help greatly appreciated.
Regards - Jason
February 22, 2011 at 11:59 am
Search this site for "concatenate FOR XML PATH".
February 23, 2011 at 12:26 am
Thanks for the pointer, Lutz. I've searched SSC as suggested, and it seems that the XML functionality is only available in SS2005 and later. Unfortunately, although I'm using 2008 SS app, the server itself is 2000 so I'm limited to 2000 syntax.
Regards - Jason
February 27, 2011 at 5:12 pm
jason-772533 (2/23/2011)
Thanks for the pointer, Lutz. I've searched SSC as suggested, and it seems that the XML functionality is only available in SS2005 and later. Unfortunately, although I'm using 2008 SS app, the server itself is 2000 so I'm limited to 2000 syntax.Regards - Jason
Then the following article will help, a lot!
http://www.sqlservercentral.com/articles/Test+Data/61572/
--Jeff Moden
Change is inevitable... Change for the better is not.
February 28, 2011 at 2:31 am
Thanks Jeff - really interesting article. I kind of agree with you in the 1st paragraph - I'd rather not be doing it, but someone wants the 'comments' concatenated rather than 'on seperate rows'. If only people would take the data in the way it was intended !
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply