Question

Looking for the SQL statement to retrieve the content db id of WSS_Content (only available at the SQL level). In what table is this id stored?

  • when I ran cmdlet Get-SPContentDatabase for a list of all content and services DBs, this DB is not returned in the results, which means SharePoint does not recognize it as a DB in use, so it is only at the SQL level.
  • My theory is that it was dismounted from the main Web application in SharePoint (which doesn’t delete it from SQL)
Was it helpful?

Solution

If the database is still attached but stopped, you can retrive them using PowerShell.

$webapp = Get-SPWebApplication -Identity https://yourWebApp.com
$cdb = $webapp.ContentDatabases
$cdb | Select-Object Name, Id, Status

Which would return the Name of the db, it's ID and current status (online/disabled).

If it has been dismounted, the db does not have any relation to SharePoint anymore. If the database still exists in SQL, you can run this query but that might put your Database in a unsupported state.

Read more here: Support for changes to the databases that are used by Office server products and by Windows SharePoint Services

SELECT [Name], [Value]
FROM [WSS_Content_DBName].[dbo].[DatabaseInformation]
WHERE [Name] = 'Id'
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top