Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Storing ADOBE PDFs in SQL Server

Author  Topic 

soberhi
Starting Member

2 Posts

Posted - 2002-05-10 : 09:40:32
Hi. I am a new-bie, so please be gentle (my background is more web developer than DBA).

I have a whole slew of Adobe PDF files that are stored in the SQL Server database. The database has grown considerably because of this. Could someone either advise me how else to do this (I was kinda thinking about storing these as files outside the database and jsut saving the paths in the SQL Server database).

What is normally done? Has anyone found a good article on this? I have tried searching around a little bit, but have not found anything helpful.

Thanks for reading this and I appreciate all efforts on my behalf.

SoberHi

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2002-05-10 : 09:51:44
you're on the right track.....storing large word, pdf, spreadsheets is not a great idea for SQL...it can do it...but not advised.


going the path direction is best....search here for PATH + DOCS or BLOB...or LARGE + FILE + SQL...Robvolk and Merkin have passed the most advice on this subject.

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-05-10 : 09:55:47
quote:
Could someone either advise me how else to do this (I was kinda thinking about storing these as files outside the database and jsut saving the paths in the SQL Server database).

THANK YOU! THANK YOU! Someone who is actually SANE! (unlike me)

I have to heartily agree with you, you should save the PDF files on the hard drive and store the path to that file in the database table instead.

Take a look at some ASP sites and read up on the ADO Stream object. These should help you get started:

www.4guysfromrolla.com
www.15seconds.com
www.asp101.com
www.aspalliance.com
www.learnasp.com

Essentially, you would create an ADO recordset that includes the (image?) column where the PDF contents are stored, then create a Record object for each row (PDF file) you want to export, then create a Stream object that reads that column. It sounds more complicated than it really is, I may be overcomplicating it as well. I haven't done this personally, but I've read several articles that have done something similar to this; it is definitely do-able.

Once you have the PDF data in a Stream, you use the SaveToFile method to write the contents to a disk file. You'll need to create new file names for each document, but that's pretty easy (since you will be looping through the recordset anyway, you can include an incrementing counter and add the number to the file name) and then store the generated filename in the table with a simple UPDATE statement (you could even use the ADO recordset Update method)

I wish I could be more help. I may also have seen the article on ASPToday, but you'd have to subscribe to the site in order to read it. I know there are articles on ASPToday that work with image files, you could modify them. The code is not the same as changing the content type on a ASP page to match the contents, it's all strictly done as binary write operations.

HTH

Go to Top of Page
   

- Advertisement -