x

change row text to single column

I want to combine multiple text by id till next id

ID           text                    
12           car                    
12           boat                    
12           house                    

into

id text
12 car, boat, house
more ▼

asked Oct 13, 2009 at 09:29 AM in Default

John Graff gravatar image

John Graff
11 1 1 1

John, if you use one of these methods can you mark one of the answers as the one you accepted?
Oct 13, 2009 at 12:33 PM graz ♦
I see that many people simply ask questions and dont follow them
Oct 14, 2009 at 09:24 AM Madhivanan
(comments are locked)
10|1200 characters needed characters left

3 answers: sort oldest

Will the approach at the bottom of this article work?

http://www.sqlteam.com/article/using-coalesce-to-build-comma-delimited-string

more ▼

answered Oct 13, 2009 at 09:38 AM

graz gravatar image

graz ♦
525 2 4 5

(comments are locked)
10|1200 characters needed characters left
more ▼

answered Oct 13, 2009 at 09:49 AM

Madhivanan gravatar image

Madhivanan
1.1k 1 3 6

(comments are locked)
10|1200 characters needed characters left
more ▼

answered Oct 13, 2009 at 12:28 PM

ERussell gravatar image

ERussell
11

Note that this method wont work for multiple rows as OP specified
Oct 14, 2009 at 09:27 AM Madhivanan
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x1951
x35

asked: Oct 13, 2009 at 09:29 AM

Seen: 1205 times

Last Updated: Oct 13, 2009 at 09:36 AM