473,383 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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
2 9457
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: grahamhe | last post by:
Hi, I have recently upgraded .NET from 1.0 to 1.1 and now an application I am writing is no longer uploading the files, any ideas? I have posted the relevant code below... <%@ Page...
0
by: wschlichtman | last post by:
I am running into speed issues when attempting to work with larger image files, e.g., 5 M/Pixel photos. I have been experimenting with in-memory working images which are scaled down to a more...
35
by: Stan Sainte-Rose | last post by:
Hi, What is the better way to save image into a database ? Just save the path into a field or save the image itself ? I have 20 000 images (~ 10/12 Ko per image ) to save. Stan
8
by: Christopher Kurtis Koeber | last post by:
Dear All, Recently I created a thread about trying to load a particular ICON image that GDI plus could not load. I realized that GDI plus definitely does not support it because it had a certain...
9
by: Tom John | last post by:
Hi I am storing images in an access database, based on an MSDN article. The code i use to store is as follows: <code> 'Create the command object Dim command As New...
12
by: Lance | last post by:
hey all, first time vb.net 2005 user, after sticking vb6 out for a long time... anyway, using this code ====================== Dim FS As FileStream = File.OpenRead(Filename) Dim theImage As...
4
by: LT.Ang | last post by:
I am developing an application that possibly opens very large images - bmp, jpeg, tiff. I have 2 questions: Language: C#, VS .NET 2003. 1. When the program opens a BMP image, the amount of...
4
by: samatair | last post by:
Hi I have being working on a form. The form allows 5 image files to be uploaded with other user details. All the 5 image files are uploaded at the same time (with a single submit button click)....
1
by: chennaibala | last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading. i develop...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.