How-To Mount Existing Content DB to a SharePoint Web application

Two scenarios:

1) Web Application already exist and you want to change the Content DB.

2) Web application should be created with existing Content DB.

Let’s look at them one by one.

1: Web Application already exist and you want to change the Content DB:

It’s better to stop the application pool for this web application from IIS.

Delete the Content DB (if you don’t need it).

Open the SharePoint Management Shell (with elevated privileges) and run the following PS Command:

Mount-SPContentDatabase -Name WSS_Content_DB_ToAttach -WebApplication http://mywebapplication:port

The above command will attach the content Database and now execute the below PS command in same window.

Upgrade-SPContentDatabase

This command will upgrade the DB to the final version of your SharePoint Farm.

To Learn how to use this command: Upgrade-SPContentDatabase -examples

2: Web application should be created with existing Content DB:

This is very simple. Just mention the name of existing content DB while creating the new Web Application in the Central Admin.

SharePoint-ContentDB

Optionally if desired you can execute the above command to upgrade it.

How to find Content DB Version:

If you dont have the version of the content db then you have to run the following script:

1: SELECT Version, UserName     2: FROM Versions   3: WHERE VersionId = ‘00000000-0000-0000-0000-000000000000’   4: ORDER BY Id DESC

or open the version table directly (Not recommended).

SELECT *

FROM Versions

WHERE VersionId = ‘00000000-0000-0000-0000-000000000000’

ORDER BY Id DESC

More About SharePoint Versions:

The below links could help you to find what is latest version released by Microsoft.

SharePoint 2010: http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=224

SharePoint 2013: http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=346

Advertisements

One thought on “How-To Mount Existing Content DB to a SharePoint Web application

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s