Note: This post relates to SharePoint 2007.
I’ve recently worked on a project that required direct access to the SharePoint content and Shared Service databases for reporting purposes. Although accessing the SharePoint databases directly is generally a no-no and is not supported, the types of reports required were not possible, or would have a serious impact on performance if the object model was used.
Also, as the code reports would be generated with SQL scripts any possible changes to the database structure with future service packs would be easy to resolve and not affect the code controlling the report generation.
The main reason for this post is to show how to retrieve the database details for a web application’s shared service database, as this is not easily accessible with the object model. But to start with, I’ll describe how to retrieve the database details for the content databases.