Discussion:
[freetds] Retrieve large binary object via freebcp
klaas.decanniere
2014-02-05 15:32:36 UTC
Permalink
Hello,

I'm trying to retrieve a large binary entry from a database with freebcp. The database is on a remote windows server (sql server), the data should be downloaded to a linux machine.
The data is in fact a ZIP file and can be up to 4 Gb in size.

The query in itself works both in sql server management studio and in freebcp as the correct object is retrieved

On windows and using bcp as a client, I can sort-of retrieve the "binary blob" using the following format file:
11.0
1
1 SQLBINARY 8 0 "" 1 BinaryContent ""

(the file as written is larger than the original (padding??) so that some unzip utilities can't read it, but it can be made to work)

When I try this on linux with freebcp, I get complaints:
bcp: Unrecognized datatype found in format file

Looking around for an alternative datatype I tried SYBBINARY, but this ends in
Msg 20049, Level 4
Data conversion resulted in overflow

How can I get the zipfile out of the database intact and unconverted and unchanged?
(linuxODBC is also installed if that helps)

Thank you very much for your help,

Klaas

Freetds is version 0.91 on Gentoo linux, the database is SQL Server 2008.
Frediano Ziglio
2014-02-25 10:02:10 UTC
Permalink
Post by klaas.decanniere
Hello,
I'm trying to retrieve a large binary entry from a database with freebcp.
The database is on a remote windows server (sql server), the data should be
downloaded to a linux machine.
Post by klaas.decanniere
The data is in fact a ZIP file and can be up to 4 Gb in size.
The query in itself works both in sql server management studio and in
freebcp as the correct object is retrieved
Post by klaas.decanniere
On windows and using bcp as a client, I can sort-of retrieve the "binary
11.0
1
1 SQLBINARY 8 0 "" 1 BinaryContent ""
(the file as written is larger than the original (padding??) so that some
unzip utilities can't read it, but it can be made to work)
It's not clear what you want to achieve. Do you want a way to retrieve a
column of data containing a file from command line?

Bcp output contains some additional headers/footers.
Post by klaas.decanniere
bcp: Unrecognized datatype found in format file
Looking around for an alternative datatype I tried SYBBINARY, but this ends in
Msg 20049, Level 4
Data conversion resulted in overflow
Ptobably you want sybimage
Post by klaas.decanniere
How can I get the zipfile out of the database intact and unconverted and unchanged?
(linuxODBC is also installed if that helps)
Surely you can write a program to do it
Post by klaas.decanniere
Thank you very much for your help,
Klaas
Freetds is version 0.91 on Gentoo linux, the database is SQL Server 2008.
Frediano

Loading...