I try to import image data into a sql server 2008 db with code like this:
INSERT INTO [TAB] (ID_PHOTO,PHOTO)
VALUES(
CAST('333EFB54-7062-E043-F088-FE0A916C0297' as uniqueidentifier),
CONVERT(varbinary(max),'0xFFD8FFE000')
)
The string is just a dummy but when I make the insert I found something like this in the database
0x307846464438464645303030
which isn't exactly what I expected. Does anybody know what I have done wrong?
varbinary
has a maximum size of8000
which may not contain the whole image, you should useimage
data type instead (which can hold up to2,147,483,647
bytes. Also saving large data of image in database is not recommended, we can save the URL instead (and make sure the URLs are some kind of permanent links). – Watchman