Baserat på givna uppgifter kan jag erbjuda dig detta:
UPDATE t
SET accno = p.accno
FROM [table 1] t
INNER JOIN (
SELECT
DISTINCT fileref, stuff(
(
Select char(13)+char(10) + IsNull( D2.viaccno, '' )
From vi_accno As D2
Where D2.vifileref = A.FileRef
For Xml Path(''), type
).value('.', 'nvarchar(max)')
, 1, 2, '') As accno
FROM
vtindex a
) as p
ON p.fileref= t.fileref