SharePoint Database SQL Query Tips4

Where are the Documents or files we uploaded or attached stored in sharepoint? Many of them know, those files are stored under SharePoint Content Database. But on which database table, on which format?

For that, i did a quick research on that, and here i give those results,

  • The AllDocStreams table in SharePoint Content Database stores the Document Contents.
  • The Contents of the document are stored in Content Column in the AllDocStream table.
  • The Content column is the Image Datatype, (stores in the format of Binary).

I provide a simple SQL Query to retrieve the Document List Name,File Name, URL, and the Content (Binary Format)

SELECT AllLists.tp_Title AS ‘List Name’,
AllDocs.LeafName AS ‘File Name’,
AllDocs.DirName AS ‘URL’,
AllDocStreams.Content AS ‘Document Contnt (Binary)’
FROM AllDocs
JOIN AllDocStreams
ON 
AllDocs.Id=AllDocStreams.Id
JOIN AllLists
ON
AllLists.tp_id = AllDocs.ListId

By Sooner, I’ll come up with other interesting Sql Query Tips.

Shantha Kumar
Shantha Kumar
Articles: 278

24,849 Comments

  1. hi,
    I want a way access attachment file in sharepoint list through sql query,

    I dot’n understand,where is attachment files store ? all content of attachment file store in the WSS_Content database or just address of attachment file in my hard, store in the WSS_Contetnt database in sql?

    Can you give me a sql query for access all content of attachment file?
    thanx.

Comments are closed.