This blog will describe how to attach, detach a content database.
Below is the scenario –
You created a new Site collection in SharePoint 2010.
Now you want this site collection to work with your existing Content database.
Simply you can be asked that you have an existing content database and you need to attach it with the new Site collection.
How to attach existing Content Database to new SharePoint Site Collection?
So you have created a new Site collection and want to attach existing content Database.
Let’s start this process.
First, you need to Remove Existing Content database which is associated with your new site collection.
To do this, go to Central Admin
Application Management, under databases you will find Manage content Databases. click on that link.
Select your web application, your content database will be shown. click on Content Database. On the new page, you need to select a checkbox “Remove content database” and click OK.
So you have successfully removed Content Database from the new Site collection.
Next step is to attach an existing content database to your new site collection.
There could be 2 scenarios.
1. ) Your existing Content Database is associated with one site collection – In this case, you need to run below command to detach this content database.
You will be asked to confirm this, please type Y and hit enter. Then you may run Mount command.
2.) Your existing Content Database is not associated with any site collection – In this case no problem, no need to Dismount it directly you can run Mount command.
Mount-SPContentDatabase "WSS_Content_Old" -DatabaseServer "DBServerName" -WebApplication "http://siteurl" -AssignNewDatabaseId
Here is output for this –
Id : 2617bb2a-b21a-4f77-bcc4-539a987a9639 Name : WSS_Content_Old WebApplication : SPWebApplication Name=SharePoint – 1000 Server : servername CurrentSiteCount : 1
Now you may restore a bak file to this site if required. Also, you may deploy your WSP solution, if required.
So you are done with Attaching existing content database with the new Site collection.