views:

253

answers:

1

I'm making a small asp.net mvc app. in which I have to compute data from several CSV files ( between 5 to 10 files).

The application must provide upload and download actions for these files.

The part where I don't have experience is the data base. What column type should I use? text, image, binary ? the size of a file will be betweent 80KB to 500KB

+1  A: 

The types TEXT, NTEXT and IMAGE are obsolete - do not use them for new development. They will be removed from a future SQL Server version for good.

For SQL Server 2005 and up, use VARCHAR(MAX) / NVARCHAR(MAX) if you're dealing with pure text files (like source code or CSV files), or VARBINARY(MAX) if you're dealing with binary files.

Those allow up to 2 GB of storage for each single file, and you can use all the usual T-SQL string functions on them to manipulate them (the (N)VARCHAR(MAX) fields, that is).

If you're using SQL Server 2008, there's also an additional option - the FILESTREAM attribute on VARBINARY(MAX) columns. This allows you to store the files in the SQL Server machine's file system (instead of the database tables) while preserving transactional and data integrity.

FILESTREAM is recommended for files that are typically and usually larger than 1 MB in size, or if you ever need more than 2 GB (since you can't store more than 2 GB in a regular VARBINARY(MAX) column).

Marc

marc_s
Mention no limit FILESTREAM types as well for completeness.
whatnick
Thank you all!Solved, I guess I will use FILESTREAM.
Andrei T. Ursan