Storing an Image Into SQL Server 2008

Clif
Clif used Ask the Experts™
on
Yes, I'm aware of the arguments against storing an image in SQL Server, but it has to be done none the less.

So, everything I've run across seems to imply that you need VB pr C# (or some other dev platform).  Is it not possible to write a SQL query of sorts to copy an image from a BMP file into a BLOB field of SQL Server (and a corresponding query to take it from the field and create a file)?

If so, how?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2012

Commented:
>>Is it not possible to write a SQL query of sorts to copy an image from a BMP file into a BLOB field of SQL Server (and a corresponding query to take it from the field and create a file)?<<
SQL Server used to ship with a utility called TextCopy to do this, but since it is no longer available you will have to resort to using OPENROWSET()

Author

Commented:
faiga16,

Halfway there.

The first link you posted seems to work ok, in as much as there is now a table in the database with some data that looks like it might be right.

However I have not yet the ability to retrieve the image from the database.  Is this possible strictly through SQL Server, or do I need another app?
Faiga DiegelSr Database Engineer

Commented:
You cannot use SQL management tool to read and open that stored image file since it is stored in a binary format. You will have to create your own UI/tool for this. There is no general UI/tool available online (atleast from what I have searched before), but you can always create a simple UI form to retrieve it. There are couple of sample codes in the net. Search Retrieving image BLOB SQL 2008.

Author

Commented:
Well, at least I can put it into the database.

Thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial