SQL Server, how to save images and attachments in the database. Is better to store images into the database or into the filesystem?
Hi Guys, This is the first post of the year and i want to do my very best wishes for a great 2022! I hope it's a year of joy, peace and happiness for everyone! Well, this year we will start with a question! Where is it better to save images and attachments? ...within the database or on the file system? yes but, some might ask. How can I save images and attachments in the database? ..easy. Enjoy the read mates! Read and save images and attachments into the database Suppose we have a table that contains data relating to our products. One possibility is to store the image of our product in a column. In our example the table will have this structure: CREATE TABLE Products ( Id int identity (1,1) PRIMARY KEY NOT NULL, Code Varchar (20), ImageProduct VarBinary (MAX) ) Our image will be stored into the ImageProduct field of type VarBinary . Obviously in that same field we can store everything we want, a binary file, an application, an attachment and so on .. The first ...