1

My table looks something like this:

BinFiles
0x1101ABB1C...
0x2202DEE2F...
0x3303GHH3I...

I tried this to get a single line:

SELECT
    STUFF((SELECT d.BinFiles
    FROM dbo.demo d
    WHERE d.ID = dd.ID
    FOR XML PATH('')), 1, 1, '') BinFiles
FROM
    dbo.demo dd

How can I do this? Or is this possible for varbinary data (size issues)?

I'm using SQLServer 2019. The varbinary columns are part of a pdf file (1Mb per file). I need to join these columns into a single row for export again as a pdf file.

0

1 Answer 1

0

I solved my problem with this query. If you have many 'bin' files that are part of one file you can try this:

DECLARE @concatData varbinary(max),@FileName varchar(255)
SELECT @concatData = COALESCE(@concatData, 0x) + BinFiles,@FileName=FileName
FROM test.dbo.demo2 ORDER BY RowNum select @concatData as BinFiles,@FileName as FileName

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.