Show Primary and Secondary Accounts in a table
If you use sql server 2017 you could use the STRING_AGG function
and your query would look like

SELECT testRelate.AccountRef AS ACref,STRING_AGG(testRelate_2.AccountRef, ', ')
FROM testRelate AS testRelate_2 
INNER JOIN  testRelate AS testRelate_1 ON testRelate_2.[Relationship Reference] = testRelate_1.[Relationship Reference] 
RIGHT OUTER JOIN testRelate ON testRelate_1.[Primary Relationship Reference] = testRelate.[Primary Relationship Reference]
GROUP BY testRelate.AccountRef


but if not, it would have to be with FOR XML PATH Y STUFF