Thursday, January 30, 2014

Subquery returning csv written values in a Main Query Column

select 
    categorie, 
    stuff((select ', ' + id
           from table2 t2 where t1.categorie = t2.categorie
           for xml path('')),
          1,2,'') [IDs]
from table1 t1

No comments:

Post a Comment