I have been asked to extract all the files from one of the SharePoint farm and put into the share drive where users can access it. I was looking around on the web and we found an article, but SQL query is incorrect in this article as Content Column is not resides in the DOCS Data-view. So, I end-up in modifying this script with creating an INNER JOIN between DOCS and DOCSTREAMS to get the binary content for the files. I have attached here is the code and screenshot of it.
Hope this helps.