Click here to Skip to main content
14,664,462 members
Articles » Database » Database » SQL Server
Posted 1 Feb 2013

Tagged as


7 bookmarked

Rebuilding Master Database in SQL Server

Rate this:
4.29 (4 votes)
Please Sign up or sign in to vote.
4.29 (4 votes)
17 Aug 2013CPOL
This tip shows a case study of how to rebuild master database


In this tip, I would like to show you how to rebuild the master/system database in SQL Server 2008 R2. Recently, I faced a problem related to the master database. My instance was unable to start due to master file corruption.

Case Study

Recently, one of my instances was corrupted and I was unable to restart SQL Server. I did the following steps to get it back. First I checked the SQL Server ERRORLOG. Please go through the following steps.

Step 1: Check the error log where it is showing master was corrupted.

Image 1

Step 2: Rebuild system databases from command prompt. Go to the following path and run setup as follows:

C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\SQLServer2008R2

Image 2

Step 3: Once the above command runs successfully, check in the summary.txt file as follows and look at the Requested action.

Image 3

Step 4: Start SQL Server service.

Image 4

Step 5: Connect to the instance. But you cannot see any user defined databases. The rebuilding process has created a fresh master database so there are no other databases and all previous configuration values are lost.

Image 5

Step 6: Now we can restore the master database to get the previous configuration settings. Go to command prompt and run server in single user mode as follows:

Image 6

Step 7: Connect to the instance and take new query to restore master database. Once we restore master database, then we can get all the previous configuration values including user defined databases.

Image 7

Step 8: Click on Connect button and connect to the instance as follows:

Image 8

Step 9: Restore master database as follows

Image 9

Step 10: Restart SQL Server instance in multi user mode and connect to SQL Server Management Studio. We can see all user databases as follows:

Image 10


Sometimes, the rebuild process may fail if there is problem with files present in Binn\Templates folder. Once you check summary.txt file, let's say it is saying one message as follows:

Configuration error description: The file C:\Program Files\Microsoft SQL Server \
MSSQL10_50.MSSQLSERVER \MSSQL\Binn\Templates\master.mdf is missing

In the above scenario, we have to copy file (master.mdf) from SQL Server dump or DVD into Binn\Templates folder and retry.


We can summarize the key points as follows according to BOL regarding rebuilding system databases:

  • SQL Server 2000
    • We can use RebuildM.exe
    • Need setup media for system database files
  • SQL Server 2005
    • We can use setup.exe
    • Need setup media for setup.exe and system database files
  • SQL Server 2008
    • We can use setup.exe
    • Setup media not required and system database files are there in Binn\Templates folder

Happy learning!


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Instructor / Trainer OptimizeSQL Technologies
India India
Mr. Kareem Syed is a senior SQL Server Trainer and working as Technical Consultant.

You can visit my blog at

Comments and Discussions

-- There are no messages in this forum --