sql server - return a string of comma delimited numbers from a sql query -
this question has answer here:
how can return comma delimited string using sql server?
select id, (<<somequery tableb b (b.id = a.tablebid)>>) tablea
and have return results like:
1, '11, 12' 2, '22, 33'
you can use stuff(), see demo here
select id ,stuff((select ', ' + cast(data varchar(10)) [text()] b tablebid = a.id xml path(''), type) .value('.','nvarchar(max)'),1,2,' ') comma_output group id
Comments
Post a Comment