3

Is it possible to store image having size 3GB in SQL Server?

I know it seems like unrealistic scenario but I am curious to know if its possible to save the image in database in any way ?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Gaurav123
  • 5,059
  • 6
  • 51
  • 81
  • 1
    I would suggest store Image in Application Directory and store its path in SQLserver – Jaydip Jadhav Apr 06 '16 at 10:13
  • yes I know the same. But I want to know if its possible to store the image in database ? – Gaurav123 Apr 06 '16 at 10:14
  • 1
    You **cannot** store anything larger than 2 GB in a SQL Server table - the `varbinary(max)` datatype to handle binary data (like files) has a hard, system-given 2 GB limit ([official MSDN documentation](https://msdn.microsoft.com/en-us/library/ms188362%28v=sql.110%29.aspx) on `varbinary`). If you have files larger than 2 GB, you need to use the `FILESTREAM` functionality in SQL Server – marc_s Apr 06 '16 at 11:29
  • @marc_s that page isn't about FILESTREAM. The correct page is [here](https://msdn.microsoft.com/en-us/library/gg471497.aspx#storage) - the 2 GB limit doesn't apply for filestream storage – Panagiotis Kanavos Apr 06 '16 at 11:33
  • Oh, I think it's not so unrealistic. First, replace *Image* by *Video*, and you are already there. And picture are getting bigger and bigger. The *Google Art Project* hosts images of 30,000 x 30,000 Pixels, e.g. [Van Gogh - Starry Night](https://upload.wikimedia.org/wikipedia/commons/e/ea/Van_Gogh_-_Starry_Night_-_Google_Art_Project.jpg) – SQL Police Apr 06 '16 at 11:46

1 Answers1

1

Microsoft recommends you use the file stream, for objects over 1MB in size. Within your table the image will be represented a VARBINARY(MAX) (the normal 2GB limit will not apply).

David Rushton
  • 4,915
  • 1
  • 17
  • 31
  • @marc_s not according to [MSDN](https://msdn.microsoft.com/en-us/library/gg471497.aspx#storage) : `The standard varbinary(max) limitation of 2-GB file sizes does not apply to BLOBs that are stored in the file system.` – Panagiotis Kanavos Apr 06 '16 at 11:30
  • @PanagiotisKanavos: ah - you're right - `FILESTREAM` gets around the 2 GB limit - thanks ! – marc_s Apr 06 '16 at 11:32
  • @marc_s there are [other options as well](https://msdn.microsoft.com/en-us/library/hh403405(v=sql.110).aspx#CompareFileTable) like FileTables that expose file paths and the older RBS (remote storage) – Panagiotis Kanavos Apr 06 '16 at 11:37
  • @PanagiotisKanavos: `FILETABLE` is based on `FILESTREAM` - it's not something totally new/different .... – marc_s Apr 06 '16 at 11:38