5 Replies - 3958 Views - Last Post: 15 April 2010 - 11:51 AM Rate Topic: -----

#1 djlakshmi  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 72
  • Joined: 22-March 10

can a zip file be stored in a sql database

Posted 14 April 2010 - 11:23 PM

hello all,

im a student and doing a project to automate a process. For which i ve to download files from clients site.. my doubt is can zip files be stored in sql database. if its possible means how can i achieve this..


need help!

good day.
Is This A Good Question/Topic? 0
  • +

Replies To: can a zip file be stored in a sql database

#2 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 267
  • View blog
  • Posts: 1,476
  • Joined: 07-April 08

Re: can a zip file be stored in a sql database

Posted 15 April 2010 - 05:36 AM

Quick answer is no.

Now for the more informative answer.

You do not physically store images,videos,zips, etc in a database. What you would need to do is create a folder structure to download to and then store the path to that folder in the database.
Was This Post Helpful? 0
  • +
  • -

#3 danny_kay1710  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 28
  • View blog
  • Posts: 358
  • Joined: 27-April 08

Re: can a zip file be stored in a sql database

Posted 15 April 2010 - 05:40 AM

Well actually you technically could store it within the database BUT you would need to convert the file into a base64 string first then store it in a TEXT field that didn't have a length restriction.

Some databases also support binary fields which can be used for Pictures I think even Access can be configured in this way but I could be wrong.

Take a look at the System.Text.Encoding namespace. It may help you find out how to convert to Base64

NOTE: if the files are going to be big, I would strongly advise against storing into a database. Base64 will make the file bigger in terms of storage requirements

This post has been edited by danny_kay1710: 15 April 2010 - 05:42 AM

Was This Post Helpful? 0
  • +
  • -

#4 keakTheGEEK  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 107
  • View blog
  • Posts: 344
  • Joined: 23-February 10

Re: can a zip file be stored in a sql database

Posted 15 April 2010 - 09:53 AM

View Postdjlakshmi, on 14 April 2010 - 10:23 PM, said:

hello all,

im a student and doing a project to automate a process. For which i ve to download files from clients site.. my doubt is can zip files be stored in sql database. if its possible means how can i achieve this..


need help!

good day.


Search on binary, varbinary, varbinary(Max) and image data type (SQL 2005/2008). We used image data type to provide file version control in an application where users can check in and out files (.pdf, doc(x), xls(x), .jpeg, .bmp, etc). You will need to implement a stream reader/writer to interact with the data stored in your database. There are several articles online that give examples on how to do this.

So, my answer to your question is yes you can. Read this article. Has some useful information, but there are several out there just search online.
Was This Post Helpful? 0
  • +
  • -

#5 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 267
  • View blog
  • Posts: 1,476
  • Joined: 07-April 08

Re: can a zip file be stored in a sql database

Posted 15 April 2010 - 10:49 AM

There really is no reason to ever do it that i can find, which would be the reason for my no answer. Storing binary data like that can potentially open cans of worms you do not want to be apart of.

I refer you to the following quote:

Quote

It should be noted that in all "I want to store random binary stuff in my database" scenarios, it's generally not ideal. Sure, it sounds cool, but it's just not what databases do well and they tend to do it under protest. Consider long and hard why a filesystem solution is not preferred before traveling down this path.

which is posted here:
Post

This post has been edited by rgfirefly24: 15 April 2010 - 11:43 AM

Was This Post Helpful? 0
  • +
  • -

#6 keakTheGEEK  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 107
  • View blog
  • Posts: 344
  • Joined: 23-February 10

Re: can a zip file be stored in a sql database

Posted 15 April 2010 - 11:51 AM

View Postrgfirefly24, on 15 April 2010 - 09:49 AM, said:

There really is no reason to ever do it that i can find, which would be the reason for my no answer. Storing binary data like that can potentially open cans of worms you do not want to be apart of.


I agree. Storing binary data can open up a can of worms, but does that mean throw that option out all together? I think to do it or not depends on what your project requirements are. I have no idea what the OPs project requirements are. The OP just asked can you do it and the answer is yes you can.

We store files in the database for a file version control feature in an application we support and it seems to work well. However, as you mentioned we are experiencing a small can of worms with integrating replication as we originally went with image data type, but for updatable subscriptions you need to use binary/varbinary, so we have to change column data types for a few tables. Small can of worms, yes. End of the world, not yet ;-)

Probably in the OPs particular situation, it's not a good idea (who knows). However, s/he did not ask if it was a good idea or not. Also, let them try it and find out for themselves whether or not it is a good idea for their particular situation. I think it would be great experience.

This post has been edited by keakTheGEEK: 15 April 2010 - 11:56 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1