sql server - return a string of comma delimited numbers from a sql query -


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

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -