Search code examples
sqlsql-server-ce

How can I do something like "STRING_AGG" in Sql Server Compact?


everybody

I want to make something like STRING_AGG in Sql Server Compact.

For example, I want to flatten the code column in the table below:

+----+--------+  
| Id | Code   |  
+----+--------+    
| 1  | 256987 |   
| 1  | 256985 |   
| 1  | 356994 |  
+----+--------+  

So I will get something like that:

+----+------------------------+   
| Id | Codes                  |   
+----+------------------------+      
| 1  | 256987, 256985, 356994 |   
+----+------------------------+   

Thanks in advance!


Solution

  • Your best bet will be to do it using C# (string.Join).