1

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 
1
  • 4
    Google "SQL Server string aggregation" Commented Oct 9, 2015 at 11:00

2 Answers 2

1

Try,

 SELECT STUFF( (SELECT ',' + Id FROM My_Table ORDER BY Id FOR XML PATH('')), 1, 1, '') 

Original_Post_Here

Sign up to request clarification or add additional context in comments.

Comments

0

Another way

DECLARE @str VARCHAR(1000) SELECT @str = coalesce(@str + ',', '') + a.[Your Column] FROM ( SELECT DISTINCT [Your Column] FROM [your Table] ) a SELECT @str 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.