Click here to Skip to main content
12,758,462 members (29,801 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


7 bookmarked
Posted 31 Jan 2013

Rebuilding Master Database in SQL Server

, 17 Aug 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
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.

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

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

Step 4: Start SQL Server service.

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.

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:

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.

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

Step 9: Restore master database as follows

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:


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

You may also be interested in...

Comments and Discussions

QuestionWhat solution is this? Only pictures? Pin
kuklei3-Aug-16 3:16
memberkuklei3-Aug-16 3:16 
QuestionRE:Rebuilding Master Database in SQL Server Pin
lokeber3-Dec-14 8:36
memberlokeber3-Dec-14 8:36 
Answerit help you Pin
Maks Lorenc18-Aug-14 22:49
memberMaks Lorenc18-Aug-14 22:49 
Questionvery very good Pin
yahya_iranmanesh27-Jun-13 0:47
memberyahya_iranmanesh27-Jun-13 0:47 
QuestionGreat guide Pin
Member 1004948813-May-13 11:42
memberMember 1004948813-May-13 11:42 
SuggestionOne another solution Pin
Adam Gorge18-Feb-13 0:22
memberAdam Gorge18-Feb-13 0:22 
QuestionThe formatting... Pin
OriginalGriff31-Jan-13 9:18
mvpOriginalGriff31-Jan-13 9:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170217.1 | Last Updated 17 Aug 2013
Article Copyright 2013 by Kareem.S
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid