I want to convert my found data to a single column
My data is
Id
------
3
4
5
that record I want to this format
id
=======
3,4,5
I want to convert my found data to a single column
My data is
Id
------
3
4
5
that record I want to this format
id
=======
3,4,5
Try,
SELECT STUFF( (SELECT ',' + Id
FROM My_Table
ORDER BY Id
FOR XML PATH('')),
1, 1, '')
Another way
DECLARE @str VARCHAR(1000)
SELECT @str = coalesce(@str + ',', '') + a.[Your Column]
FROM (
SELECT DISTINCT [Your Column]
FROM [your Table]
) a
SELECT @str