How to Store and Retrieve Images Using MsSQL (Server Management Studio)

Posted by Joe Majewski on Stack Overflow See other posts from Stack Overflow or by Joe Majewski
Published on 2010-03-11T18:49:55Z Indexed on 2010/03/11 18:54 UTC
Read the original article Hit count: 246

Filed under:
|
|
|

I am having difficulties when trying to insert files into an MsSQL database. I'll try to break this down as best as I can:

  1. What data type should I be using to store image files (jpeg/png/gif/etc)? Right now my table is using the image data type, but I am curious if varbinary would be a better option.

  2. How would I go about inserting the image into the database? Does Microsoft SQL Server Management Studio have any built in functions that allow insertions of files into tables? If so, how is that done? Also, how could this be done through the use of an HTML form with PHP handling the input data and placing it into the table?

  3. How would I fetch the image from the table and display it on the page? I understand how to SELECT the cell's contents, but how would I go about translating that into a picture. Would I have to have a header(Content type: image/jpeg)?

I have no problem doing any of these things with MySQL, but the MsSQL environment is still new to me, and I am working on a project for my job that requires the use of stored procedures to grab various data.

Any and all help is appreciated. Thank you very much for your responses!

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server