0

I followed Microsoft's command bcp db..someTable ​format ... to create a fmt file. The table contains a varbinary(max) column.

The resultant fmt file looks like this

13.0

1

1 SQLCHAR 0 0 "\r\n" ...

When I use this fmt file to bcp "SELECT bin FROM..." queryout... I get a corrupted PNG file.

I went back to check older fmt files, and they look like this

10.0

1

1 SQLBINARY ...

So I edited the new fmt file by changing the data type column to SQLBINARY and it works! The PNG file can now be opened.

Is this a bug with bcp 13.0? Why is the varbinary(max) column becoming SQLCHAR in the generated format file?

  • It's not corrupted, it's just a `0x` hex character string. You need the `-n` or `-N` option, see the docs https://learn.microsoft.com/en-us/sql/tools/bcp-utility?view=sql-server-ver15#n – Charlieface Oct 27 '21 at 06:01
  • @Charlieface thanks! The Microsoft example of `bcp format` was using -c! You are right with -n – Drake Orfeo Oct 27 '21 at 08:10

0 Answers0