För 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, '')
För alla rader i TabellA:
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