STUFF ( character_expression , start , length ,character_expression )
select TcodMedInst_GUID,stuff((SELECT ',' + DeptName+'|'+guid FROM TcodDeptHosContrast AS t WHERE t.TcodMedInst_GUID = tb.TcodMedInst_GUID FOR xml path('')), 1, 1, '') Dept from TcodDeptHosContrast tb
group by TcodMedInst_GUID