467,149 Members | 1,218 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,149 developers. It's quick & easy.

BCP out image files not working

We have a table in our SQL2005 db with a varbinary(max) column in it.
In this field we store images and pdfs that the user has uploaded in
our .net 2.0 web app. I'm attempting to get the images out via sql
using the bcp utility (-n option for preserving native format).

The bcp command is not failing.
The image file is being created correctly (filename and file size are
intact).
Opening the image results in a "Preview not available" message.
BCP'ing out the PDFs in the exact same fashion works a treat.

Any ideas how to bcp out images? Or alternatives to bcp?

Thanks!!
Jon
Oct 10 '08 #1
  • viewed: 9015
Share:
2 Replies
I found out that in the bcp process, an extra 8 junk hex characters
are added to the start of the file. Take them out and the image is
perfect once more
Oct 10 '08 #2
(fr*******@gmail.com) writes:
I found out that in the bcp process, an extra 8 junk hex characters
are added to the start of the file. Take them out and the image is
perfect once more
Those are not junk characters. That is the length of the data.

To achieve what you want, use this format file:

9.0
1
1 SQLBINARY 0 0 "" 1 col ""

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Oct 10 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by wschlichtman | last post: by
35 posts views Thread by Stan Sainte-Rose | last post: by
8 posts views Thread by Christopher Kurtis Koeber | last post: by
12 posts views Thread by Lance | last post: by
4 posts views Thread by LT.Ang | last post: by
4 posts views Thread by samatair | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.