原始数据:
sql语句
SELECT DISTINCT l.family_id, STUFF((SELECT ','+ CAST(a.name AS VARCHAR(50)) FROM (SELECT DISTINCT family_id,name FROM dbo.Addresses) a WHERE a.family_id=l.family_id FOR XML PATH('')),1,1,'' ) isc_id FROM dbo.Addresses l
结果数据: