单表:
select
( SELECT CAST(name AS VARCHAR(10))+'、' AS [text()]FROM profession_domain
WHERE id in('06dbdbec-0189-410f-96ec-300d431f58f9','aaa6229b-c31a-4967-a03e-46d6f419d01b')
ORDER BY id
FOR XML PATH('')) as name
from profession_domain
多表:
select b.name,b.profession_domains,
( SELECT CAST(name AS VARCHAR(10))+'、' AS [text()]
FROM profession_domain a
WHERE a.id in(b.profession_domains)
ORDER BY a.id
FOR XML PATH('')) as domainname
from doctor b