Which data type should be used for saving images in database? [closed] Which data type should be used for saving images in database? [closed] sql-server sql-server

Which data type should be used for saving images in database? [closed]


The image data type has nothing to do with images. I don't know why it exists. It is legacy.

Store the images like you would store any other blob: varbinary(max).

The issue whether to store blobs in the database at all has been discussed before. Note, that the answers there are very opinionated and subjective. It is clearly wrong to say that one should always store blobs inside out outside of the database.


You can use the below data types for BLOBs on sql server:

Binary: Fixed size up to 8,000 bytes.

VarBinary(n): Variable size up to 8,000 bytes (n specifies the max size).

VarBinary(max): Variable size, limit of 2 GB.

What Is a BLOB?


I would suggest you could save the image urls in the database, against your product id. But if you are requesting upto 500 urls at a time, I would suggest perhaps introducing a CDN in the middle to cache the Image URLs. Will have a big impact on performance