Friday 16 November 2012

Attach/Add an existing Content Database to a sharepoint Webapplication

Scenario: you have the content database from the same server or from your production MSSQL server. Now you want to attach this content database and use it. There are few ways to do that:
1) database attach using SP CA
let's assume that the content database you want to attach has the name 'WSS_Content_New'. You already have a webapplication. Open SP CA-->application management-->content databases-->select the right webapplication --> see the attached content database-->select it-->from drop down select 'offline'--> also check mark-->remove content database--> click ok on the pop-up warning message. [Do not be scared with the pop-up message as the database will still remain in the SQL-DB and can be used in future if needed]-->now come back to manage content databases page and you will see that no more databases are associated with this webapplication-->click on the add a new content database--> in content database text box there will be wss_content_somerandomGUID remove that and type wss_content_new-->ok and now the database is attached. and you should be able to navigate to the webapplication and it will show you the site which resides in the attached content database.
    $ The above process is easy but I encountered the following error:
"The attach operation cannot continue because another object in this farm already contains the same ID. Each object in a farm must have a unique ID. In order to proceed with the attach operation you must assign a new ID to this database. To attach this database with a new ID, use the "stsadm.exe -o addcontentdb" operation with the -assignnewdatabaseid parameter. Note that if this new database and an existing database contain the same site collections, attaching this database will likely result in orphaned site collections due to conflicts between the two databases. "
    $ As the error mentions you can use the stsadm command which we will discuss later
    $ The possible cause for this error is - it's already being used by another webapplication. Check for every webapplication and its associated content database to make sure that this content database is not already being used by any other webapplication and try again.
2) using stsadm command:
stsadm -o addcontentdb -url http://server:port/ -databasename WSS_Content_New -assignnewdatabaseid
(If you happen to get the above stated error then only u need to use -assignnewdatabaseid parameter)
3) creating a new webbapp
open SPCA-->create or extend a webapplication-->create a new webapplication--> in content database text box there will be wss_content_somerandomGUID remove that and type wss_content_new-->fill-out other details-->click ok
    $ After performing all the above stated steps correctly, if you still get 404 webpage not found error, it may be possible that the content database does not have any sites. To check that navigate to the manage content database page-->select the appropriate webapp and see the content database' sites column if it says 0 you cannot see the site when you try to navigate. You can of-course create the new site in the new content database.
how to check?
navigate to the site and you will see the site.
BENEFIT: This is a part of the SharePoint backup and recovery using database attach and detach method. You can use this method to attach a moss 2007 content database to the MOSS 2010 webapplication and have a new look and feel!!!

2 comments:

  1. useful information on topics that plenty are interested on for this wonderful post.Admiring the time and effort you put into your blog!..
    cheaterland removal

    ReplyDelete
  2. Thanks a lot its working perfectly

    ReplyDelete