Substitute for STRING_AGG pre SQL Server 2016 - Stack Overflow SELECT STRING_AGG(ID) ID, (SELECT Country, City FOR JSON PATH) Json FROM Places GROUP BY Country, City I managed to get a similar result in SQL Server 2016 with the code below (But with my actual amount of data and columns, this solution is too slow )
String_agg for SQL Server before 2017 - Stack Overflow Can anyone help me make this query work for SQL Server 2014? This is working on PostgreSQL and probably on SQL Server 2017 On Oracle it is listagg instead of string_agg Here is the SQL: select