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 select '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 from alldocs join DocStreams on alldocs.id=DocStreams.DocId join alllists on alllists.tp_ID = alldocs.ListId where 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 /***/