insert a word document into sql server database?

user560498 picture user560498 · Dec 28, 2011 · Viewed 7.5k times · Source

I feel quite overwhelmed with the variety on technologies I would need to use for the above task. I've searched the stack overflow stocks but couldn't pinpoint a solid check list of steps to do this.

I would like to get an overview of the steps/tools that need to be used when inserting a word document into a database.

I thought about:

  1. reading the word file as a FileStream.
  2. deserializing it into an xml object (word ml).
  3. somehow (not sure how) insert the word ml into a xml column in sql server.

is it possible to read word ml using the XMLSerializer object ? how would I then insert it to the database ?

Edit: I actually need to perform operations on the stored data like finding nodes using xpath, hence my need to store it as xml...

Answer

user806549 picture user806549 · Dec 28, 2011

You should either go with FileStream or ordinary BLOB-storage. FileStream does require a little more initial work, and I have had problems upgrading certain already installed databases to use this. Depending on your ability/willingness to reinstall servers to get this to work, you should certainly do a proof-of-concept before going too far. Technically, I've never had problems with using BLOBs

Some research has been done as to which should be preferred depending on your usage pattern. Ie. if your files are greater than 1Mb on average and you need fast read access, you might be better off using FileStream.

I've only rarely seen the performance difference myself, but I do prefer FileStream from a design viewpoint.

Take a look at:

http://technet.microsoft.com/en-us/library/bb933993.aspx

http://www.mssqltips.com/sqlservertip/1489/using-filestream-to-store-blobs-in-the-ntfs-file-system-in-sql-server-2008/