• Robert (8/28/2008)


    I'm also having trouble implementing this without corruption of the file after it's undergone a round trip. I am importing a text file using OPENROWSET and as far as I can see that arrives in the varbinary field perfectly. The query:

    SELECT DATALENGTH(FileData) FROM TestFiles

    returns a number exactly equal to the test file size.

    However when I output it back to a file using the options you specify for bcp, I get a file that is 4 bytes longer than the original. The 4 extra bytes are right at the beginning of the file before the expected data starts and are as follows (in hex):

    B5 42 00 00

    Any ideas?

    try to remove -N in the bcp queryout.