Posted by: Shantham | April 14, 2009

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
JOIN AllLists
AllLists.tp_id = AllDocs.ListId

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

Read more…



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

    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?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: