Click here to Skip to main content
12,898,569 members (64,473 online)
Rate this:
Please Sign up or sign in to vote.
See more: SQL-Server

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

Posted 14-Nov-12 8:46am
Sergey Alexandrovich Kryukov 14-Nov-12 14:46pm
Yes, but why?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Please see my comment to the question. However, it can do it with BLOB:[^],[^].

Rate this: bad
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.

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 14 Nov 2012
Copyright © CodeProject, 1999-2017
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