I work in SQL Server 2008 R2
I have a parent table and a child table (one to many relationships). What I would like to do is query the parent table, and also include a field from the child table, aggregated into a comma separated row.
So, if the parent table is called Person with the identifier field, FirstName and LastName, and the child table is called the child and child tables, the ParentID field (FK for the parent table), FirstName and LastName ... I would like to return a dataset like this:
ParentFirstName = Mike
ParentLastName = Davis
KidsFirstNames = Susie, David, Alex
I thought there was a way to do this using the XML path, but I can't remember the syntax.
Thanks in advance.
source share