SQL Command to List In-Use SharePoint Databases

First, find the name of the SharePoint Config Database in the registry if you don’t already know it:

“HKLM\Software\Microsoft\Shared Tools\Web Server Extensions\12.0\Secure\ConfigDb”

Then in SQL Server Management Studio run this query:

SELECT o.[Name] AS 'DatabaseName',<br />
    Instance.[Name] AS 'DatabaseInstance',<br />
    [Server].[Name] AS 'DatabaseServer'<br />
FROM [SharePoint_Config_DB].[dbo].[Objects] AS o<br />
    INNER JOIN [SharePoint_Config_DB].[dbo].[Classes] c on c.id = o.classid<br />
    LEFT JOIN [SharePoint_Config_DB].[dbo].[Objects] AS Instance ON o.ParentId = Instance.Id<br />
    LEFT JOIN [SharePoint_Config_DB].[dbo].[Objects] AS [Server] ON Instance.ParentId = [Server].Id<br />
    WHERE c.Fullname LIKE '%Administration.SPConfigurationDatabase%'<br />
    OR c.Fullname LIKE '%Administration.SPContentDatabase%'<br />
    OR c.Fullname LIKE '%Administration.SharedDatabase%'<br />
    OR c.Fullname LIKE '%Administration.SearchSharedDatabase%'<br />

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s