Friday, September 14, 2007

BLOB field size && MS SQL

You can use datalength function to get BLOB (or any other field or expression) size in bytes. For example for 2 it will return 4 (2 is integer, which takes 4 bytes on my system), for '2' it will return 1 ('2' is one char, 1 byte-per-char on my system). For BLOB or IMAGE it will return actual size of data stored in this field. Example:

SELECT datalength(ITEM_THUMBNAIL) from members WHERE ID_MEMBER=177;

No comments: