sql server - Comma separated results in SQL -
i have following code create comma delimited list results:
declare @liststr varchar(max) select @liststr = coalesce(@liststr+', ' ,'') + institutionname education studentnumber= '111' select @liststr the problem creating 1 massive comma delimited line. need return comma separated list per row.
so if simon has been part of 2 institutions, expect:
"institution1, institution2" as didnt supply clause expect results show each row in database.
use for xml path('') , stuff() follows gives same comma seperated result
select stuff((select ',' + institutionname education ee ee.studentnumber=e.studentnumber order sortorder xml path('')), 1, 1, '') liststr education e group e.studentnumber here fiddle
Comments
Post a Comment