Trying to take existing solutions and abstract it so I dont have to rewrite code each time. I imagine this must exist already but I only been able to find custom implementations. Picturing fn_tableToConcatStrings( tbl Table)
Asked
Active
Viewed 72 times
-1
-
Answer here varies between databases. https://stackoverflow.com/questions/49264626/sql-server-stuff-based-on-condition#comment85532740_49264626 is a question from yesterday that covers the Microsoft answer (and even that answer depends on what version of MSSQL you are using) – Twelfth Mar 14 '18 at 19:39
-
Was looking for something more abstract that will apply to any table regardless fields. Thanks though – Vinh Ton Mar 14 '18 at 22:57
-
Which [DBMS](https://en.wikipedia.org/wiki/DBMS) are you using? "SQL" is just a query language, not the name of a specific database product. Please add the tag for the database product you are using `postgresql`, `oracle`, `db2`, `sql-server`, ... – Mar 15 '18 at 16:48
-
See [here](https://stackoverflow.com/questions/tagged/string-aggregation+sql) – Mar 15 '18 at 16:49
-
Gotcha, sql-server – Vinh Ton Mar 15 '18 at 22:30
1 Answers
0
I used the built in LISTAGG function in Oracle to do this all the time. This function is only available I think in Oracle 10g and above. You can see the documentation here https://docs.oracle.com/cloud/latest/db112/SQLRF/functions089.htm#SQLRF30030