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
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
PingBack from http://wiki.dailynewsabout.com/archives/337