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

android - questions about switching from C2DM to GCM -

c++ - Qt setGeometry: Unable to set geometry -

batch file - How to extract all multi-volume RAR archives from subfolders of a folder? -