SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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.

share|improve this answer
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 Apr 30 '11 at 14:11
OK - in that case you may be able to use the Dismount-SPContentDatabase PowerShell cmdlet to remove the DB from the configuration database. See I strongly recommend against any manual changes to the database as you will be left in an unsupported state. – Benjamin J Athawes May 1 '11 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 ($ -eq "CDB-A") {
share|improve this answer
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 May 21 '11 at 13:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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