Extracting documents directly from a SharePoint database

Last month at Tech-Ed, I asked many of my SharePoint friends, and a few vendors, how to do this. I got answers ranging from “You can’t” to “You’ll need to buy our utility”. They all told me that I should just add the content database back to my SharePoint instance and then use the WebDav or some other utility (sometimes commercial) to extract the documents in bulk. This wouldn’t work, because I had upgraded to WSS 3.0 and this was a WSS 2.0 database. Well, it may have worked, but I was saving it as a final option.

Instead, I searched the Web and found a posting by Mark Jen where he posted the code on how to do this. His code does what I suspected was possible – just rip through the items in the dbo.Docs table, and stream out the Content fields. It handles the creation of the folders as well!

Thanks Mark!