Reputation: 3
I have a field with multi value with diffent IDs For example :
ID | Email|
+--+------+
|1 |a@mail|
|2 |b@mail|
|3 |c@mail|
I would like to have this output
|Email |
-------------------+
|a@mail;b@mail;c@mail|
I tried with STUFF and XML PATH based on this post ListAGG in SQLSERVER but I does not work.
Any help will be appreciated
Best Regards
Upvotes: 0
Views: 46
Reputation: 1269643
This should work in SQL Server:
select stuff( (select ';' + email
from t
for xml path (''), type
).value('.', 'nvarchar(max)'
), 1, 1, ''
)
Upvotes: 2