Skip to content
Advertisement

SQL Server – Concatenate – Stuff doesn’t work

I have this query in SQL Server and I want to concatenate using stuff the ‘Products’ column, but I don’t know why this doesn’t work…

And the result is:

And I want this:

Also I used SELECT DISTINCT in the query but the result is the same…

So, where can be the mistake?

Advertisement

Answer

SQL Server 2017 and Later Versions

If you are working on SQL Server 2017 or later versions, you can use built-in SQL Server Function STRING_AGG to create the comma delimited list:

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