Saturday, January 21, 2012

Concatenate rows into a text string

I needed to concatenate multiple rows of a table together in Caché SQL. I did this using XMLAGG, which returns all of the values used within a specified column as a concatenated string.  If I'd wanted the data to be comma separated then I could have used the LIST function instead.

SELECT ReportName,XMLAGG(ReportLine) As Report FROM Reports GROUP BY ReportName

If you want to do the same thing with a different database then Stack Overflow thread might be able to help.

No comments:

Post a Comment