Missing SQL 2005 Model Database

Posted on



We went to install an SRS database on our SCCM 2007 server for FEP 2010, but when attempting to create a new report server db, we were getting error 1807 “System.Data.SqlClient.SqlException: Could not obtain exclusive lock on database ‘model’. Retry the operation later.”  It was discovered that the install failed because the Model database had become corrupted and detached.  And more unfortunately someone removed backups of the database (lesson learned: do monitor the backups of your system databases!) 

Our initial attempts to restore Model was to ‘import’ the model db from another server with the exact same SQL version.  While the import was successful and the database was automagically moved into System Databases, the error continued.  Knowing that a service pack in effect reinstalls SQL, we upgraded to SQL 2005 SP4.  There was still no joy.  A proposed solution was to do a cut-over of SCCM to a new server with a clean install of SQL and SCCM.  However, in my experience, that would have caused more issues resulting a longer drawn out resolution path.  So I wanted to avoid that.  Based upon a forum thread somewhere, we had indications that the error was now being caused by Model not having the proper system   database ID value.  To confirm this, we used a Microsoft support case.

The issue was caused by the `model` db having the incorrect database_id.  It was registered as 7, but all system databases must have the specific db_id, with model being ID 3.  Which means that model was actually a user database, despite being listed in the System Databases category. To fix the issue, all user databases, model, and msdb were detached. Then attaching them in order model, msdb, user dbs resulted in creating model with ID 3 and msdb with ID 4. The ability to create databases was then fully functional again…

Advertisements

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