Today, we are going to see the query for returning Webs and Site Collections available in the Database (WebApplication).
–Returns Total Number of Site Collections in WebApplication
select count(*) as ‘Total Site Collection’ from sites
–Returns Root Site Title for each Site Collection available in WebApplication
select Title as ‘Root Web Title’, Sites.RootWebId, Sites.Id as ‘Site Collection ID’ from webs inner join Sites on Webs.Id = Sites.RootWebId
–Returns Total Web Sites in WebApplication
select count(*) from Webs
–Returns WebSite Title and Site Id
select Title as ‘Site title’,FullUrl, SiteId as ‘Site Collection Id’ from Webs order by SiteId
–Returns Total number of Web Sites under each SiteCollection
select SiteId, count(*) as ‘Total Sub Sites’ from Webs inner join Sites on Sites.Id = Webs.SiteId group by SiteId
Webs Database stores the informations on Web Sites.
Sites Database stores the informations on Site Collections.
Great article, thanks for the information.
By: Builder on March 20, 2009
at 4:13 am
[…] SharePoint Database SQL Query Tips2 Tags:Coding SharePoint, Custom Sharepoint, MOSS, moss customisation, SharePoint Customization, tips and tricks, workarounds Share Home SharePoint 2010 Public Beta Home Correctly Debugging with Visual Studio 2008 […]
By: Using SPContext Class | Rehman Gul Professional Blog on January 9, 2010
at 12:47 pm