Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to list all SharePoint databases

Status
Not open for further replies.

neualex

Programmer
Feb 26, 2008
53
US
Hi guys,
Does anyone know how to list all SP databases programmatically (.net) as the Central Administration / Operations / Perform Backup page does?

Hope you can help!
Thanks,
...Alex
 
Don't know about .net, but the stsadm command can do this on a per-URL basis:

[tt]stsadm -o enumcontentdbs -url <url>[/tt]

I hope this helps.
 
After posting that reply, I found myself wondering how you would programatically get all the URLs (given that you need to run [tt]stsadm -o enumcontentdbs[/tt] for each URL)...

[tt]stsadm -o enumzoneurls[/tt] might help. It does list all the web applications, but it also shows the alternate URLs too so you'd need to filter the output, perhaps just looking for the Default URLs.

Anyway, I'm probably heading off on a tangent here as you didn't actually ask that question... ;-)
 
Thanks!
I ended up in the Central Administration page since I didn't find a way to list all databases.

You can programatically list all web apps, site collections, subsites, if you need the code, just let me know.

...Alex
 
SPWebServiceCollection webServices = new SPWebServiceCollection(SPFarm.Local);

foreach (SPWebService webService in webServices)
foreach (SPWebApplication webApplication in webService.WebApplications)
foreach (SPSite siteCollection in webApplication.Sites)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top