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.
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.
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.
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.