Sunday 12 June 2011

Attatching a Content DB to a Web Application

For each Web Application you create in SharePoint, by default, there is a single Content DB that is assigned to it. Typically, the steps for creating a web application are as follows:
  1. Launch your Central Administration web site.
  2. On the Quick Launch bar to the left of the page, click on Application Management.
  3. Under the SharePoint Web Application Management heading, click on Create or extend Web application.
  4. Click on Create a new Web Applicaiton.
  5. The Create New Web Application page requires some information before creating your new web application. I won’t go through all of this in detail, but let’s pay particular attention to the Database Name and Authentication section
Now once your content db has been created, you’ll need to go back to the Application Management screen. From there, try the following:
  1. Click on Content databases.
  2. On the right of the toolbar, look for the Web Application drop down. Make sure you change this to match the web app you’re trying to replace the content db for. I find that sometimes this is defaulted to the Central Admin web application which is not what we want.
  3. Click on the database name link, this should bring up the Manage Content Database Settings page. Change your Database status to Offline and check Remove content database. Click OK. This content db shouldn’t contain anything since we just created this web application.
  4. We should now be redirected back to the Manage Content Databases page. Click on Add a content database.
  5. The only thing you need to change on this page is the Database Name field. Set this to the name of the content db you want to add. Set the search server and click OK.
Now typically this is a smooth operation, however, if you encounter the error below:
Attaching this database requires an upgrade, which could time out the browser session. You must use the STSADM command ‘addcontentdb’ to attach this database.
Open up a command prompt window, and type the following stsadm command deom the 12 hives folder:

stsadm -o addcontentdb -url http://server01/ -databasename WSS_Content
(Note: sometimes copy paste to command prompt produces ascii characters so better re-type - and quotes "" if any)
  
There are other arguments you can use for this command, to see a list of those, type:
stsadm -o addcontentdb

Once the command has completed successfully, try refreshing your site. If you have any issues at all with this, drop me a line.

0 comments: