SELECT distinct Profile,stuff((select distinct ', ' + Specialization FROM TM_Specialization tms INNER JOIN TM_Profile tmp
ON tms.ProfileID=tmp.ProfileID where tms.ProfileID =tm_p.ProfileID
FOR XML PATH('')
) ,1,1,'') as Specialization
FROM TM_Profile TM_P INNER JOIN TM_Specialization TM_s
ON TM_S.ProfileID=TM_P.ProfileID