Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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, '')
Original_Post_Here
Add a comment
Another way
DECLARE @str VARCHAR(1000) SELECT @str = coalesce(@str + ',', '') + a.[Your Column] FROM ( SELECT DISTINCT [Your Column] FROM [your Table] ) a SELECT @str
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.