Sql-server – How to restore the SQL Server model database

databasedatabase-restoresql serversql-server-2005

Since a few days ago, when I try to start the SQL Server service, it fails with the following error logged to the NT Application Log:

An error occurred during recovery,
preventing the database 'model'
(database ID 3) from restarting.
Diagnose the recovery errors and fix
them, or restore from a known good
backup. If errors are not corrected or
expected, contact Technical Support.

How can I restore (or rebuild) the model database, when the master database is fine but I can't run sql commands against the database (or connect to it from the management studio) since SQL Server does not even start in this case?

I do have backups in a backup container/volume (all backups in a single file on a second HD). I believe the recovery model of the model database to be SIMPLE.

I didn't really find much info in the docs or the internet (like this), as in most articles either the service actually runs so you can run commands against it, or the master database is corrupt as well.

Some selected entries of the ERRORLOG:

  • Attempting to recover in-doubt distributed transactions involving Microsoft Distributed Transaction Coordinator (MS DTC) [..]
  • CHECKDB for database 'master' finished without errors [..]
  • Starting up database 'model'.
  • WARNING: did not see LOP_CKPT_END.
  • Error: 3414, Severity: 21, State: 2.
  • An error occurred during recovery, preventing the database 'model' (database ID 3) from restarting. Diagnose the recovery errors and fix them, or restore from a known good backup. If errors are not corrected or expected, contact Technical Support.
  • SQL Trace was stopped due to server shutdown. Trace ID = '1'. [..]

Microsoft SQL Server 2005 – 9.00.4053.00, on Windows NT 5.2 (Build 3790: Service Pack 2)

Any ideas? Thanks very much!

Best Answer

As it is "only" the model database, i recommend only to copy a model database from a working instance. Rebuild all system databases is not necessary in this case.