Attach existing Content Database to new SharePoint Site Collection

This blog will describe about 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 existing content database and you need to attach it with new Site collection.

So you have created a new Site collection and want to attach existing content Database.
Lets 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 new page you need to select a checkbox "Remove content database" and click on OK.

So you have successfully removed Content Database from new Site collection.

Next step is to attach existing content database to your new site collection.

There could be 2 scenario.

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.

Dismount-SPContentDatabase "WSS_Content_Old"

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 new Site collection.

Protected by Copyscape


  1. Nice blog for upgrading content database.
    It helped me alot in my current task.


Post a Comment

Popular posts from this blog

CAML Query in SharePoint 2010

Calling REST APi from server side code - C#

All about SharePoint 2010 Content Type Hub

SharePoint Interview Questions and Answers

Calling ASP.Net WebMethod using jQuery AJAX