|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Extracting documents from a databaseHow do I extract documents from a SQL Server database? I'm off ill so
I don't have the table structure to hand but I'm pretty sure there's some kind of BLOB field and a text field with the document name, I'm not sure whether they are Word documents of PDFs but I don't suppose that makes much difference. There are a lot of documents to extract, and I'd like to do it as an iSQL script that just extracts every document in the database. How do I do this? I'm a little more familiar with Oracle SQL*Plus than I am with MS, but I've also used Sybase before. Phil. PhilHibbs (sna***@gmail.com) writes:
> How do I extract documents from a SQL Server database? I'm off ill so The best is probably to write a small program in C# or VB .Net. I have> I don't have the table structure to hand but I'm pretty sure there's > some kind of BLOB field and a text field with the document name, I'm > not sure whether they are Word documents of PDFs but I don't suppose > that makes much difference. > > There are a lot of documents to extract, and I'd like to do it as an > iSQL script that just extracts every document in the database. How do > I do this? I'm a little more familiar with Oracle SQL*Plus than I am > with MS, but I've also used Sybase before. a very quick example on http://www.sommarskog.se/blobload.txt that you can work from. You can't really do it in an SQL script, because an SQL script can't write to a file. You could use BCP for the task, but then you would need something to drive BCP, as you would have to run BCP once for each document. -- Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx You can try a command utility called textcopy.exe that you can find in the
BINN directory of a SQL2000 instance. At the command line, type textcopy -? will give the command line usage. The -O option is for exporting a text or image value. For an example of how it can be used, you can find it is used to import text/image files in two batch files in the Install directory of a SQL2000 instance. The two batch files are pubtext.bat and pubimage.bat, respectively. Linchi Show quote "PhilHibbs" wrote: > How do I extract documents from a SQL Server database? I'm off ill so > I don't have the table structure to hand but I'm pretty sure there's > some kind of BLOB field and a text field with the document name, I'm > not sure whether they are Word documents of PDFs but I don't suppose > that makes much difference. > > There are a lot of documents to extract, and I'd like to do it as an > iSQL script that just extracts every document in the database. How do > I do this? I'm a little more familiar with Oracle SQL*Plus than I am > with MS, but I've also used Sybase before. > > Phil. > > On 13 Oct, 04:16, Linchi Shea <LinchiS***@discussions.microsoft.com>
wrote: > You can try a command utility called textcopy.exe that you can find in the No luck, doesn't seem to be there in SQL Server 2005.> BINN directory of a SQL2000 instance. At the command line, type textcopy -? > will give the command line usage. The -O option is for exporting a text or > image value. Phil Hibbs. PhilHibbs (sna***@gmail.com) writes:
> On 13 Oct, 04:16, Linchi Shea <LinchiS***@discussions.microsoft.com> If you can find an SQL 2000 installation CD, you can get the samples> wrote: >> You can try a command utility called textcopy.exe that you can find in >> the BINN directory of a SQL2000 instance. At the command line, type >> textcopy -? will give the command line usage. The -O option is for >> exporting a text or image value. > > No luck, doesn't seem to be there in SQL Server 2005. from that CD and build textcopy yourself. You will need to put NTWDBLIB.DLL in system32 on the SQL 2005 machine, since SQL 2005 does not come with any files for DB-Library. Then again, writing a simple .Net app that performs the work of textcopy should not be a big deal. It's a lot easier in .Net than with DB-Library. I have a quick demo at http://www.sommarskog.se/blobload.txt. -- Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx |
|||||||||||||||||||||||