For 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, '')
For alle rækker i tabel A:
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