see below example
Input Table Output Table
------------ --------------
a b a b
------------ --------
1 a 1 a,b
1 b ------> 2 c
2 c Query
select a,substring(b,0,Len(b)) as b from
(
select distinct a,
(
select b + ',' as [text()] from
(
select 1 as a,'a' as b
union all
select 1 as a,'b' as b
union all
select 2 as a,'c' as b
) as tbl_a where tbl_a.a=tbl_b.a
for xml path('')
) as b
from
(
select 1 as a,'a' as b
union all
select 1 as a,'b' as b
union all
select 2 as a,'c' as b
) as tbl_b
)
as tbl_c
follow steps given below for modifying above query as per your table structure
replace underline section with your table-name
a=your columnname e.g. id
b=column name which you want to combine with ','
another example
how to get a single row from a table from multiple rows[
^]
Happy Coding!
:)