DECLARE @listStr VARCHAR(MAX) SELECT @listStr = COALESCE(@listStr+',' ,'') + Convert(nvarchar(8),Month) from fees where studentid in (101,102) group by studentid,month SELECT @listStr
SELECT StudentId, Months = STUFF((SELECT ', ' + CONVERT(NVARCHAR(2), [Month]) FROM FEES f WHERE f.StudentId = a.StudentID FOR XML PATH ('')), 1, 2, '') FROM Fees a GROUP BY StudentId
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)