Wednesday, March 21, 2012

Image data type Size

I need to store images in MS SQL. I have the upload procedures and stuff but I'm missing the point about the image data type size.

It is supposed to be able to store up to 2Gb!!! but when I declare the data field image I can't specify the max size for the field and by default is 16 !!

16 bytes!! what can I do with that?
How can I insert a file?

Please helpThe pointer to the data is the only thing stored in this database row. The data is stored elsewhere and can be up to 2G. You don't get to specify the size.

Bill|||Thanks for the reply!

But that leads me to this question: How can I write the Insert Statement for the image field?

create table ImgTest (
imgID Int,
imgFName varchar(30),
imgFType varchar(30),
imgFile image
)

All I got so far is a procedure in vb net that tryes to insert a byte array asigned to parameter value:

Insert Into ImgTest Values (1, 'file.jpg', 'image file', @.bytearray)

That's where I'm having trouble because it returns the error: "Data will be truncated" or something like that. I guess it's because it tryes to store the file in the 16bytes that are reserved for the pointer...

Oh.. I'm so lost..

Thank you!sql

No comments:

Post a Comment