Home > DeveloperSection > Forums > model db in RESTORING state,can't start SQL Server
Alex Leblois
Alex Leblois

Total Post:67

Points:471
Posted on    September-23-2015 1:33 AM

 MSSQL Server Database  MSSQL Server 
Ratings:


 1 Reply(s)
 404  View(s)
Rate this:
problem started when sysadmin received error that model is recovering.

Sometime later vendor tried to do some upgrades to the database. When they restarted SQL Server it failed to start.

Looking at error log. I found the following error

Error The database 'model' is marked RESTORING and is in a state that does not allow recovery to be run. Error: 927, Severity: 14, State: 2. Database 'model' cannot be opened. It is in the middle of a restore. Could not create tempdb. You may not have enough disk space available. Free additional disk space by deleting other files on the tempdb drive and then restart SQL Server. Check for additional errors in the event log that may indicate why the tempdb files could not be initialized.


Mayank Tripathi
Mayank Tripathi

Total Post:397

Points:3117
Posted on    September-23-2015 6:48 AM

After trying large number of alternative steps was able to fix the problem and get the database started.

Here are the steps I took:

On another SQL Server 2008 R2, I moved my model and temp db files to same location as on my problem server. Refer to this http://technet.microsoft.com/en-us/library/ms345408.aspx

Replaced model and tempdb .mdf and .ldf files on my problem server. Old files I saved in another directory just incase.

Tried to start the SQL Server services, verified error message

The database 'model' is marked RESTORING and is in a state that does not allow recovery to be run. Error: 927, Severity: 14, State: 2. Database 'model' cannot be opened. It is in the middle of a restore. Could not create tempdb. You may not have enough disk space available. Free additional disk space by deleting other files on the tempdb drive and then restart SQL Server. Check for additional errors in the event log that may indicate why the tempdb files could not be initialized.
After that I opened two separate Command Prompt windows.

Below to make it easier I call first command prompt windows CPA, and second one CPB.

in CPA run Sqlservr.exe -sInstanceName -T3608 -c -f -T3609 (note: I had to navigate to binary location) don't forget to replace InstanceName with yours
-T3608 only starts master Trace Flags documentation
-T3609 skips creation of tempdb
in CPB run SQLCMD -E -SADMIN:Servername\InstanceName replace with your ServerName\InstanceName. Using a Dedicated Administrator Connection
in CPB run sp_detach_db 'model' then go
in CPB run the following code, just replace with your file location.
CREATE DATABASE [model] ON
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.R2\MSSQL\DATA\model.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.R2\MSSQL\DATA\modellog.ldf' ) FOR ATTACH
go
in CPA you should see Starting 'MODEL' messsage
in CPA hit Ctrl+C that will show message if you want to exit hit Y
Using SQL Server Configuration Manager or Services page start SQL Server service.

After I was able to connect using SSMS.

Don't want to miss updates? Please click the below button!

Follow MindStick