Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,

Is there a way to upload a .rar or .zip file to sql server and get it back again?

Thanks,
Posted
Comments
Sergey Alexandrovich Kryukov 14-Nov-12 14:46pm    
Yes, but why?
--SA

Yes - just read it as a sequence of bytes and save it in a varbinary(max) column. You retrieve it the same way, and can then save it as a zip / rar file again.

However, I would strongly suggest against it: zip / rar files tend to be used for very large objects, and most databases have a maximum size limit as well as causing a lot of database traffic when you insert, update or select them. It might make a lot more sense to keep them in a separate file-system based folder instead, under a temporary name (a Guid for example) and store the original name and the Guid path in the DB instead.
 
Share this answer
 
Please see my comment to the question. However, it can do it with BLOB:
http://en.wikipedia.org/wiki/Binary_blob[^],
http://msdn.microsoft.com/en-us/library/bb895234.aspx[^].

—SA
 
Share this answer
 
v2

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