I have a table where an ID has possible multiple values in one column "Name".
This is my table
-----ID------Name-----
1 John
1 Jim
I what to do this:
---- ID ----- Name-----
1 John, Jim
I have a table where an ID has possible multiple values in one column "Name".
This is my table
-----ID------Name-----
1 John
1 Jim
I what to do this:
---- ID ----- Name-----
1 John, Jim
You can try this -
select a.ID,
(select b.Name +', ' from TableName b where b.ID = a.ID FOR XML PATH('')) as Name
from TableName a
group by a.ID