• SharePoint Database SQL Query Tips4

    by  • April 14, 2009 • Database, SharePoint • 2 Comments

    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.

    2 Responses to SharePoint Database SQL Query Tips4

    1. stenloves
      April 27, 2009 at 6:22 AM

      Hi, thanks for answering my post in the msdn site.

      http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/f806f177-9955-4628-907b-8fc3e854c23d/

      I’m currently wanting to create a webpart that contain hyperlink to link to latest dated document in the doc lib. But different hyperlink come from different subfolder. Any help to that?

    2. November 21, 2010 at 11:52 PM

      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.

    Leave a Reply

    Your email address will not be published. Required fields are marked *