8
votes

This question was actually posed to me this morning by one of my compadres, and it completely threw me, in so far as I didn't even realise SQL had an 'image' datatype so I've always simply gone down the route of compacting files/images etc into BLOB fields.

After having a (very) quick look around msdn the most I could really find was the info that the image datatype pages works like a blob or varbinary(max) up to a [max] size of ~2GB but past this can't seem to find too much more about it.

I'm wondering if maybe the image datatype is a way of providing indexable/searchable metadata on images within SQL...?

Does anyone have anything to offer, by way of links or explanations regarding this?

Any help would be gratefully received, so many thanks in advance of any replies!

UPDATE / Possible answer

After a little more digging I've perhaps acheived some headway with this...

It may well be that my original thoughts on what the "image" type relates to may have been somewhat misguided, maybe due to the type being titled "image" (which I apparently found quite misleading on first look) which I thought related to an image in a mimetype kinda way, but which appears to infer more of a "disk-image" or "binary-image" sort of idea.

In this way it seems that the IMAGE type was introduced to SQL before the varbinary type was allowed as a (max) field, possibly as a way of storing files in SQL in the way that is now taken for granted (by myself at least) with the use of VARBINARY(MAX)...

For Reference (both reasonably old but seem to fit the bill):

http://channel9.msdn.com/Forums/Coffeehouse/138883-Storing-Retrieving-images-from-SQL-Server-2005

http://www.basenow.com/help/Data_types_in_Microsoft_SQL_Server.asp

If anyone can offer any constructive crit on this possible answer that would be really useful in trying to understand this...

Cheers All!

2
To clarify, the platform is MS SQL Server 2005/2008 ( I think )BizNuge

2 Answers

2
votes

It is vendor dependent but generally:

A blob/image data type is a column type which stores binary data in the database separate from rest of the columns. So everytime you ask for image/blob data, database looks up the location and reads the data and send back to you.

Some vendors do TEXT data type which is the same thing wit the the difference it accepts textual data so you can put full-text indexes on them.

1
votes

As you're referencing Microsoft SQL Server, one important thing to keep in mind when choosing between IMAGE and VARBINARY data types is that Microsoft is deprecating the IMAGE type - so the fact that you did not use it is in your case a very good thing.

http://msdn.microsoft.com/en-us/library/ms143729.aspx