Skip to content
Advertisement

Sybase ASE 15 Aggregate Function for strings

I’am findind a way to aggregate strings from differents rows into a single row in sybase ASE 15. Like this:

id | Name                    Result: id | Names
-- - ----                            -- - -----
1  | Matt                            1  | Matt, Rocks
1  | Rocks                           2  | Stylus
2  | Stylus

Something like FOR XML PATH in T-SQL.

Thanks!

Advertisement

Answer

Sybase ASE does not have any string aggregate functions like list() or group_concat(); and while there is some support for FOR XML, it does not include support for the PATH option/feature.

Assuming you could have an unknown/variable number of rows to append, your only (ASE 15) T-SQL option would be a cursor-based solution.

If you find yourself working with ASE 16 you could write a user-defined function (UDF) to accomplish the task, eg: emulate group_concat() in ASE 16

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement