Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which data-type for storing images and documents in SQL Server 2005

I must extend an existing .net-Application to store images and documents (mostly pdf's) in a SQL Server 2005 database.

Which SQL Server datatype is used best for saving these files and is it meaningfull to create a separate table that holds the fields, or is it no problem to put these fields directly in the "normal" business tables, as long as the select statements do not select them (or SELECT *).

like image 461
HCL Avatar asked Jan 04 '11 21:01

HCL


2 Answers

SQL Server 2005: Blobvarchar(max)
SQL Server 2008: FileStream

like image 80
Ta01 Avatar answered Nov 15 '22 04:11

Ta01


VARBINARY or FILESTREAM

No need to store them in a separate table - there are built-in controls you can use to force it to be stored in/out of row using sp_tableoption:

http://msdn.microsoft.com/en-us/library/ms189087.aspx

http://msdn.microsoft.com/en-us/library/ms186981.aspx

http://www.microsoft.com/sqlserver/2008/en/us/wp-sql-2008-manage-unstructured.aspx

(Note that there might be benefits to storing in a separate table if you are using different filegroups and backing them up independently or something like that - but that might be considered exceptional)

like image 26
Cade Roux Avatar answered Nov 15 '22 04:11

Cade Roux