Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server
Hi,
 
Is there a way to upload a .rar or .zip file to sql server and get it back again?
 
Thanks,
Posted 14-Nov-12 8:46am
Comments
Sergey Alexandrovich Kryukov at 14-Nov-12 14:46pm
   
Yes, but why?
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 435
1 Maciej Los 335
2 OriginalGriff 278
3 CHill60 180
4 Sinisa Hajnal 180


Advertise | Privacy | Mobile
Web01 | 2.8.141022.2 | Last Updated 14 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100