Which datatype is used to store image in sql




















Which data type should be used for saving images in database? Asked 6 years, 6 months ago. Active 5 months ago. Viewed 73k times. Improve this question. Dharman Supreeth sup Supreeth sup 1 1 gold badge 3 3 silver badges 15 15 bronze badges. Though you can save the images in the database, but try to save only the image or other file file name and path in the database and store corresponding file in app folder or any other specific folder in server.

Thank you. Add a comment. Active Oldest Votes. Store the images like you would store any other blob: varbinary max. Improve this answer. VarBinary n : Variable size up to 8, bytes n specifies the max size. VarBinary max : Variable size, limit of 2 GB. Pixelomo 5, 4 4 gold badges 44 44 silver badges 57 57 bronze badges.

Hasan Fathi Hasan Fathi 4, 4 4 gold badges 34 34 silver badges 49 49 bronze badges. Lee Swainsbury Lee Swainsbury 2 2 silver badges 9 9 bronze badges. Mayur Khairnar Mayur Khairnar 15 3 3 bronze badges. The Overflow Blog. There is also a need to distinguish between images of different sizes, like thumbnails, web display images, and the like. For example, one application that I recently developed shows news items where each item has a thumbnail and main article image. Another app shows company logos in small and large sizes.

Most of the time, images can be stored on the web server and then referenced using the URL. That only requires storing the path string in the database, rather than the image itself. However, there are times that this is not feasible, such as where the app has insufficient rights on the filesystem. In those cases, you can store images directly in the database and then load them using application code. Here, lets imagine an employee database where, included with identification information, is a unique image of the individual.

I would like to import images for each employee from a source location into a table and then be able to export the image for processing later. Not sure which tool to use? Review a comparison between the tools here. For this exercise, I am assuming that you have some basic understanding of the use of Azure Data Studio logging in and connecting to a database, executing queries, etc. There is a preliminary step I must do to make this example work.

Now that I have the prerequisite work completed, I can go ahead and create a table that will hold the images. Since I am going to want to load images as new employees are hired, I can use a handy stored procedure as shown below. The procedure loosely based upon a concept offered online at msqltips.



0コメント

  • 1000 / 1000