Home > Uncategorized > Null content database and how to resolve

Null content database and how to resolve

So i have just had a fun problem. In some custom code I access the first database in the SPContentDabaseCollection against the webapplication.

This was returning a null object because the database didn’t exist. I clearly broke something when doing a system rollback.

Anyway, to solve the issue i followed the steps in the following post and it all worked.

Didn’t need to do any database hacking 🙂

Solution:
This is a case of at least 1 orphaned database associated to the problematic web application.
1. Run below powershell command to get GUID of web application.
get-spwebapplication | ? {$_.displayname -eq “Problematic Web Application Name”} | fl
2. Run this SQL query against configuration database.
select ID, Name, CAST (properties as xml) from Objects where ID = ‘GUID of webapp from Step 1’
3. The results returned from step 2 will have 1 column with the properties as xml. Click on the results and it should open a new window in SQL Mgmt studio with xml output.
4. Search for the word “m_Databases” in the xml output.
5. Carefully read through the tag that stores the above searched word. You should be able to see fld tags. Find out a tag which has fld tag with value null. This is the orphan database. Its GUID is the xml line above where you found null.
6. Cross verify all databases currently associated with the web application and make sure this database is not getting used.
7. Run below powershell script,
$webapp.contentdatabases.delete(‘ID-of-bad-content-db’)
This script will throw an object reference error. Do not worry, it works its magic under the hood.
Try to create a new site collection now and it should work.

http://mydailytechlog.blogspot.co.uk/2011/12/sp2010-cannot-create-new-site.html

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: