Posted by: Shantham | March 18, 2009

SharePoint Database SQL Query Tips1

Today onwards on daily basis, I decided to post the Sql Query to access the SharePoint Databases. To know more about the databases in Sharepoint , check my SharePoint Databases Post.
To retrieve all lists from the database, use the following query,

select AllLists.tp_Title as ‘List Title’,webs.Title as ‘Web Title’
from dbo.AllLists as AllLists
inner join dbo.Webs as webs
on webs.Id=AllLists.tp_WebId
order by webs.Title

dbo.AllLists Table contains all the lists available in WebApplication Level *

dbo.Webs Table Contains all the webs or sites available in WebApplication Level  *

Sql Query Result

Sql Query Result - Returns All Lists with Site

*If the Database configured for SiteCollection, then the table only contains the datas for SiteCollection Level.

Read more…



  1. Microsoft does not recommend touching database.

    That is the reason MS has given web services and SharePoint API’s to play with.

    However I know this is Read operation only. Hence shold not be an issue.

  2. Dear Shantha,

    I appreaciate your help by providing these queries to us. I am wondering if you could help me with creating a SQL query to find “permissions of all the objects in the sharepoint (arranged in a tree order like Site then library then folders and then items)”. Can we do 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: