Click here to Skip to main content
16,004,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello

i wants to store appendix file in a table in sql server db.
the format of files are diffrent.
bmp, doc, jpg, ini, txt, doc and all type of file.
how must i do it?

thanks
Posted

You have five options:
1. Save the file as always in the file system and store only the path in the database using some NVARCHAR data. The problem of this method is that you file have to be secured independently from the DB (otherwise it can be deleted while still listed in the DB).
2. Use BLOB (Binary Large OBject) to store the file in binary format using VARBINARY data-type. The problem with this solution is you may need a very large storage, depending on the amount of the documents you have...
3. Since SQL 2008 there is the FILESTREAM feature. This option combines 1 and 2 by using the file system as na extension of the DB. http://msdn.microsoft.com/en-us/library/bb933993(v=sql.100).aspx[^]
4. FileTables - since SQL 2012 - are an extension of FILESTREAM. This technique combines files into tables and enables accessing them via an API from simple - no DB - applications like you access the file system...
http://msdn.microsoft.com/en-us/library/ff929144(v=sql.110).aspx[^]
5. RBS (Remote Blob Storage) is an extension of FILESTREAM (also since 2012) to enable to store the files on a remote storage instead on the server...http://msdn.microsoft.com/en-us/library/gg638709(v=sql.110).aspx[^]
 
Share this answer
 
Save them on file system and only their path in the database. That way you don't need to convert them to bytearrays to save. If you absolutely have to do it, convert them into memory streams then to byte arrays and save them in the database. In this case, it is absolutely imperative to save the file name (or at least file TYPE) in the separate field.
 
Share this answer
 
Please Save into File system in root directory .
if you want to store into Database Please declare DB column varbinary type.


http://msdn.microsoft.com/en-us/library/ms187752.aspx
 
Share this answer
 
If you are using Above SQL2012 then use the FileTable[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900