I have two tables: table A holds master product data, and table B holds children product data. I would like to update table A to hold the same value of the identical column
I think this will do it:
SELECT parent_id AS ID,
STUFF((
SELECT ','+color FROM TableB a WHERE a.parent_id = b.parent_id FOR XML PATH('')
),1,1,'') AS color,
STUFF((
SELECT ','+Location FROM TableB a WHERE a.parent_id = b.parent_id FOR XML PATH('')
),1,1,'') AS Location,
FROM TableB b
GROUP BY parent_id