“A SharePoint database named ‘….. ‘already exists. You must supply another name for the new database.” – Using Sql Server BackUp and Restore of Content Database.


To create a new web application which will use an existing content database we need to do the following.

Open Sql Server Management Studio

To take back up of the database in my case it was ‘WSS_Content_fa5cc7a0686e424bbe4fc128b4a48cf4’

Right click the database select tasks select Offlinethen select Detach.

Get the mdf and ldf file for the database.

Attach the files and create a new database.

Now to Central Administration Site Application Management Create a new web application

Let the name of the database as default.

Now go to Content Database within Application Management Select the web application just created.

Click on the Database Name Select Database Status as Offline and Check Remove Content database check box.

Now click on Add Content Database In the Database Name specify the name of the new restored database.

This is the point we can get this error “A SharePoint database named ‘….. ‘already exists. You must supply another name for the new database”

The solution for this is to go to

SharePoint_Config database There run this query

delete from Objects where name=’name of restored db’;


Bye


Discover more from Nishant Rana's Weblog

Subscribe to get the latest posts sent to your email.

Unknown's avatar

Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

17 thoughts on ““A SharePoint database named ‘….. ‘already exists. You must supply another name for the new database.” – Using Sql Server BackUp and Restore of Content Database.”

  1. N,

    when i run the query i get :

    Msg 547, Level 16, State 0, Line 1
    The DELETE statement conflicted with the REFERENCE constraint “FK_Dependencies1_Objects”. The conflict occurred in database “SharePoint_Config”, table “dbo.Dependencies”, column ‘ObjectId’.
    The statement has been terminated.

    Any ideas.

    Mike

    Like

  2. Well do you think changing the sharepoint database is recommended. I spoke to people at MS and they say any changes to database is not supported by MS.

    Like

  3. Hi Kaajal, making changes to the databases are not supported i.e to either it’s structure or values inside it. However if you are just taking backup and restoring the databases it’s absolutely fine !!

    Like

  4. I am facing the same problem.
    Can anyone guide me.
    I am unable to create a new webapplication
    as it says a sharepoint database say x already exists.
    I guess some reference has been on that.
    How to remove that any idea.

    Thanks
    Shafi

    Like

  5. I received this error after my SQL disk filled up.

    I unconsumed the Site Content DB and couldn’t reconsume it.
    In order to clear the error and re-consume the site content db, I had to:
    1. free up space on sql
    2. delete the reference from the sharepoint_config db (don’t ever do this :p)

    use sharepoint_config
    go
    delete from Objects
    where name = ‘your_site_content_db_name_here’

    3. reconsume the site content db

    Like

  6. Thanks! I got stuck because my content database was still listed in Objects, but it didn’t exist anymore. Something had gone awry when I removed the content database using CA. Guessing some process hadn’t completed before I dropped the database in SQL Server. Nothing I tried cleaned it up enough to attach a backup of the database. Couldn’t even delete the web application to start over! I used the “delete from [objects] where name='[mycontactDB]'” and was then able to reattach the content database. Hate that I had to touch a SP database, but was left with little alternative (oh, sure, I could have rebuilt the entire farm–YUCK!). Fortunately, this wasn’t a production environment.

    Like

  7. Yes, this is NOT a supported method.

    Check your destination farm in Central Admin under the section Manage Content Databases. If a Content Database of the same name exists you will need to remove it before running the Mount command again.

    You can remove the database by clicking on the content database, check the delete content database checkbox and click ok.

    I hope this helps.

    Like

  8. I had the same issue Mike had. My situation was that I restored a SP2007 DB to a SP2010 WEBAPP. I got an error when trying to delete the content database via the CA (object not set to a reference or something like that) Used the stsadm deletecontentdb command to remove the DB from the webapp.

    Like

  9. Hello!
    I have the same problem. Solution:
    1- Open a SharePoint PowerShell console.
    2- Execute: Get-SpDatabase and look the database GUID.
    3- Execute: $database = Get-SpDatabase -Identity “GUID”
    4- Execute: $database.Delete()
    5- Attach your database….. Problem solved!

    I hope it´s help you

    Like

    1. Thanks Javi,
      you saved my live and farm… 🙂
      for me working perfect!!!
      Get-SpDatabase
      $database = Get-SpDatabase -Identity “My DB GUID”
      $database.Delete()

      DONE!!!

      Like

  10. I feel this is the “Right way” to do this. Your choice!
    You can test it by just changing the database in in the variable and when you are ready to run it, un-remark the last two lines.

    Jut FYI, this just removed the reference from SharePoint, you will have to delete it yourself, or you can use Remove-SPContentDatabase if you want it to delete it form SQL also.

    $ContentDB = “DatabaseName”
    Get-SpDatabase | Where-Object {$_.Name -eq $ContentDB } | Sort-Object name | ft name, type -AutoSize

    #$database = Get-SpDatabase | Where-Object {$_.Name -eq $ContentDB }
    #$database | Dismount-SPContentDatabase -Confirm:$false

    Like

  11. Get-SPContentDatabase -WebApplication “WebApplication URL here”
    Get-SPContentDatabase d04a6e13-c5e8-4355-9744-d8929ec27770 | Remove-SPContentDatabase
    # where the Guid in previous line is the ContentDatabase guid that you want to remove as it us orphaned.

    Like

Leave a reply to Nishant Rana Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Nishant Rana's Weblog

Subscribe now to keep reading and get access to the full archive.

Continue reading

Power Platform Puzzles

D365 CRM, Power Platform Tips &Tricks

Power Spark

Power Spark By Shrangarika

Van Carl Nguyen

Exploration of Power Platform

My Trial

It is my experience timeline.

Power⚡Thomas

Sharing my knowledge and experience about the Microsoft Power Platform.

Arpit Power Guide

a guide to powering up community

Welcome to the Blog of Paul Andrew

Sponsored by Cloud Formations Ltd

Deriving Dynamics 365

Deriving Solutions and features on Power Platform/Dynamics 365

The CRM Ninja

Thoughts & musings from a Microsoft Business Applications Ninja!

D CRM Explorer

Learn about Microsoft Dynamics CRM Power Platform customization and implementation and other cool stuffs

Stroke // Jonas Rapp

I know pre-stroke. I will improve who I was.

Power Melange

Power Melange By Shalinee

Clavin's Blog - PPUG.ORG

AI - Power Automate - Power Apps - SharePoint Online - Azure - Nintex - K2 - Artificial Intelligence

Sat Sangha Salon

An Inquiry in Being

The Indoencers

The Influencers & Influences of Indian Music

Monika Halan's blog

Hand's-free money management

D365 Demystified

A closer look at Microsoft Dynamics 365.

Microsoft Mate (msftmate) - Andrew Rogers

Experienced consultant primarily focused on Microsoft Dynamics 365 and the Power Platform

Manmit Rahevar's Blog

One Stop Destination for Microsoft Technology Solutions

MG

Naturally Curious

Brian Illand

Power Platform and Dynamics 365

Steve Mordue

The Professional Paraphraser

Subwoofer 101

Bass defines your home theater

SQLTwins by Nakul Vachhrajani

SQL Server tips and experiences dedicated to my twin daughters.

Everything D365

Discovering Azure DevOps and D365 Business Applications

Tech Wizard

Lets do IT Spells

XRM Tricks (Power Platform & Dynamics CRM )

Power Platform & Dynamics CRM

CRM TIPS BY PRM

Mail to crmtipsbyprm@gmail.com for queries and suggestions

nijos.dev

Giving back to the community what I have learned

Power Platform Learning

Your Go-To Resource for Power Apps, Power Automate & More

xrm CRM Dynamics

Dynamics CRM Technical & Functional Info

Dynamics 365 Blogs - Explained in unique way

Sometimes you need to look at things from different perspective.