Welcome to AspAdvice Sign in | Join | Help

SQL - Multiple rows into single column

SELECT a.id,

concatename = substring((SELECT ( ', ' + name )

FROM table b

WHERE a.id = b.id

ORDER BY id

FOR XML PATH( '' )
), 3, 1000 )FROM table a

GROUP BY id 

refer more at here:

http://code.msdn.microsoft.com/SQLExamples/Wiki/View.aspx?title=createacommadelimitedlist

Published Wednesday, May 20, 2009 7:16 PM by mo meng

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Daily News About Wikis : A few links about Wikis - Wednesday, 20 May 2009 04:14

Leave a Comment

(required) 
required 
(required) 
Enter the code you see below