I am currently trying to retrieve a single document from a DB from SP2013 environment with SQL. I have taken a snap shot of the db and am trying against it (so not touching production in any way at all)

When I do a search for the document (a .xlsx) I somehow get 91 results for it, all of which have an identical URL and file name and same version (1.0, doc library doesn't have versions enabled). Most of the results have the same size (1mb) while a few have sizes from 0-156kb.

So far no document I have managed to export has been a workable .xlsx document.

The scripts I am using are from (and modified slightly due to schema changes) https://mikesdatawork.wordpress.com/2018/05/11/find-and-extract-sharepoint-documents-with-sql/

use [WSS_Content_<NAME REDACTED>];
set nocount on

    'database'  = db_name()
,   'time_created'  = left(alldocs.timecreated, 19)
,   'kb'        = (convert(bigint,DocStreams.size))/1024
,   'mb'        = (convert(bigint,DocStreams.size))/1024/1024
,   'list_name' = alllists.tp_Title
,   'file_name' = alldocs.LeafName
,   'url'       = alldocs.DirName
,   'last_url_folder' = right(alldocs.DirName, charindex('/', reverse('/' + alldocs.DirName)) - 1)
,   'version' = allDocs.UIVersion                      
    alldocs join DocStreams  on alldocs.id=DocStreams.DocId 
    join alllists           on alllists.tp_ID = alldocs.ListId
        alldocs.LeafName = 'Line Data.xlsx' --change this to match your doc
        and alldocs.DirName LIKE '%/Dash/921%' --filter due to users using the same name in dfferent dir
order by
  alldocs.timecreated desc

You need a SharePoint farm. Due to shredded storage, you need the logic built into SharePoint to be able to stitch together the shreds.

  • I thought that would be the case. Our back up farm is currently inoperable which is the normal approach I would have taken instead of all of this^. Didn't know about shredded storage but figured it would have to be something along those lines. I'll wait 24 hours in case some one posts a work around before accepting this as the answer – Roland Feb 19 '19 at 0:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.