2

What data type should be use for files such as:

doc, xls, jpg, png, dwg

With a size of between 0.1 to 10 MB what should be?

Varbinary (x)
Varbinary (max)
Image
Marek
  • 3,555
  • 17
  • 74
  • 123
  • 4
    If you are 100% sure you want to store that kind of stuff in the db use [varbinary(max)](http://msdn.microsoft.com/en-us/library/ms188362.aspx). Don't use [image](http://msdn.microsoft.com/en-us/library/ms187993.aspx) as it is deprecated from sqlserver 2012 onwards – rene Jul 14 '13 at 12:20
  • 1
    I googled or you: http://msdn.microsoft.com/en-us/library/gg316765(v=sql.105).aspx – rene Jul 14 '13 at 12:45
  • 1
    For storing files, VARBINARY or FILESTREAM is best. http://stackoverflow.com/questions/4450432/sql-server-how-to-store-binary-data-e-g-word-file – A G Jul 14 '13 at 12:53
  • 1
    [*`ntext`, `text`, and `image` data types will be removed in a future version of SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use `nvarchar(max)`, `varchar(max)`, and `varbinary(max)` instead.*](http://msdn.microsoft.com/en-us/library/ms187993.aspx) – marc_s Jul 14 '13 at 14:20

1 Answers1

1

I would recommend you to use varbinary(max) for every file

In SQL 2012 you might use image but it wouldn't be supported in next generations of SQL Servers.

Varbinary (x) will be useful for avoiding storing larger files than desired.

Marek
  • 3,555
  • 17
  • 74
  • 123
  • 5
    Do **NOT** use `Image` anymore! It's deprecated and will be removed in a future version of SQL Server. Use `VARBINARY(MAX)` for **ALL** binary data. Same applies to `TEXT` and `NTEXT` - do **not** use those anymore. [See details here](http://msdn.microsoft.com/en-us/library/ms187993.aspx) – marc_s Jul 14 '13 at 14:17