Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to store image?

Status
Not open for further replies.

totti24

Programmer
Aug 2, 2002
32
MY

hi all. just wondering whether sql server can store images or not? if can, how am i suppose to do the inserting process. for e.g if i'm to insert a record i will write a statement insert into ........ but for images, how to insert? thanks in advance.


 
Hi there

yes it is
This is from the help file:

Binary data consists of hexadecimal numbers. For example, the decimal number 245 is hexadecimal F5. Binary data is stored using the binary, varbinary, and image data types in Microsoft® SQL Server™ 2000. A column assigned the binary data type must have the same fixed length (up to 8 KB) for each row. In a column assigned the varbinary data type, entries can vary in the number of hexadecimal digits (up to 8 KB) they contain. Columns of image data can be used to store variable-length binary data exceeding 8 KB, such as Microsoft Word documents, Microsoft Excel spreadsheets, and images that include bitmaps, Graphics Interchange Format (GIF), and Joint Photographic Experts Group (JPEG) files.

In general, use varbinary for storing binary data, unless the length of the data exceeds 8 KB, in which case you should use image. It is recommended that the defined length of a binary column be no larger than the expected maximum length of the binary data to be stored.

What kind of application will you be using?

Go to and search for insert insert image into sql 2000 (or 7 or whatever you are using)

I haven't done this myself but i know you can do it.

Transcend
[gorgeous]
 
SQL Server can store binary data, as Transcend says, but I would strongly recommend you don't try it. Instead, store the files in a normal folder and just store the filename in a varchar field in the db. This method is much easier to implement and will perform much better.

--James
 
James is right,

it is definately far less difficult to store all the images somewhere and have the filename stored in the database. This is the way we have implemented it, I just assumed that you wanted to learn how to store binary data.

Transcend
[gorgeous]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top