In my database there is a table with values below
In need a qry to get the result like this
DECLARE @TAB TABLE(SIDS INT,VALUE VARCHAR(10))
INSERT INTO @TAB
SELECT 1,'ASC'
UNION ALL
SELECT 1,'ASC'
UNION ALL
SELECT 1,'ASC'
UNION ALL
SELECT 2,'SDF'
UNION ALL
SELECT 2,'SFD'
UNION ALL
SELECT 3,'ERF'
UNION ALL
SELECT 3,'ERF1'
SELECT T1.SIDS,VALUE = STUFF((SELECT ','+T2.VALUE FROM @TAB T2 WHERE T1.SIDS = T2.SIDS FOR XML PATH('')),1,1,'')
FROM @TAB T1
GROUP BY T1.SIDS
OUTPUT
SIDS VALUE
1 ASC,ASC,ASC
2 SDF,SFD
3 ERF,ERF1