I had accidentally deleted a content database "CDB-A"(not important) without doing a detach. I also added a new content database "CDB-B" to the web application.

SP 2010 seems to hang on to "CDB-A" somewhere and keeps spitting out this in uls log -- System.Data.SqlClient.SqlException: Cannot open database "CDB-A", login failed for user (usrename).

Get-SPContentDatabase also does not return CDB-A, but if i create a new one named CDB-A, I get a message "CDB-A already exists create a new one".

How can I dereference this CDB-A from sharepoint configuration?

2 Answers 2


It sounds as though you have detached the content database from within SharePoint Central Administration but it's still present and correct in SQL server. Get-SPContentDatabase doesn't return the DB because it isn't listed in the config database.

When you "Create" (Add) the DB in Central Admin I imagine its attempting to add CDB-A to your Web application but fails due to the farm account having insufficient permissions to access it.

You will need to grant permission to the DB in SQL Server Management Studio to your SharePoint farm account (the identity of the application pool running central admin), or alternatively detach CDB-A from SQL server.

  • Its kind of the other way. CDB-A is not present in the sql server. It was not a detached content db. Get-SPContentDatabase does not return the cdb-a. New-SPContentDatabase complains that cdb-a is already present. I looked at the SharePoint_Config and I can see an entry to the CDB-A in one of those tables. Im logged in as farm admin only. But Im wary of deleting that particular row.
    – vasya10
    Commented Apr 30, 2011 at 14:11
  • 1
    OK - in that case you may be able to use the Dismount-SPContentDatabase PowerShell cmdlet to remove the DB from the configuration database. See technet.microsoft.com/en-us/library/ff607764.aspx. I strongly recommend against any manual changes to the database as you will be left in an unsupported state. Commented May 1, 2011 at 17:35

Try deleting it from PowerShell. This is how I'd do it (I'm no expert yet).

$site = get-spsite http://urlOfsiteInTheWebApplication
foreach ($db in $webapp.contentdatabases){
    if ($db.name -eq "CDB-A") {
  • 1
    The problem is its not even listed when I do get-spcontentdatabase. The site that had the cdb had already been deleted via IIS. My mistake was deleting the db directly from sql and not via remove-spsite or remove-spcontentdatabase. A few days before I checked, this error was gone, I think a reboot or some "clean up" timer service took care of it.
    – vasya10
    Commented May 21, 2011 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.