За XYZID = 1
.
select stuff((select '#'+col2+'-'+col3+'-'+col4
from TableB
where XYZID = 1
order by seq
for xml path(''), type).value('.', 'nvarchar(max)'), 1, 1, '')
За всички редове в TableA:
select stuff((select '#'+col2+'-'+col3+'-'+col4
from TableB as B
where A.XYZID = B.XYZID
order by seq
for xml path(''), type).value('.', 'nvarchar(max)'), 1, 1, '')
from TableA as A