Rebuilding system databases on SQL 2005 (or adding additional components)

SQL server is corrupt – master is damaged. You didn’t do the original install and you have to supply the media for the repair.

In the situation I’m thinking of, SQL Server was installed as part of the server build or, it might have been installed using the DVD (unlikely!) or even from a network share but either way you’re now doing it from different source media e.g. you are supplying the installation media via the two files downloaded from Microsoft VLSC. First file is the Server components (or CD 1) and the second file is the Tools (or CD 2). You must follow this process or you cannot proceed.

Extract the first file to a folder called Servers

e.g. C:\Temp\SQL2005CD\Servers

Extract the second file to a folder called Tools. This must be at the same level as the Servers folder.

e.g C:\Temp\SQL2005CD\Tools

This is documented in a Microsoft knowledgebase article here.

Rebuilding the system databases…

If you need to know the edition of SQL Server that you are going to rebuild, then look in the registry key HKLM\Software\Microsoft\Microsoft SQL Server\MSSQL.1\Setup and there is a key called “Edition”

Run the following command (in a cmd window) to rebuild the system databases using your source (case sensitive, all options req’d):

start /wait C:\Temp\SQL2005CD\setup.exe /qb INSTANCENAME= REINSTALL=SQL_Engine REBUILDDATABASE=1 SAPWD=

I recommend the use of the qb switch rather than the qn switch. qb will display dialog boxes during the process so you’re not running blind. Also, I found that I had to answer questions during the rebuild so unless you’re providing an answer file then this is another good reason to run the qb switch.

When you start the repair process you get an error partway through saying cannot find file SqlRun_SQL.msi. Upon checking the folder you can see the file there. This is all to do with the location used for the original installation. This is stored in the following registry key…
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\ \SourceList\LastUsedSource

Step through the Product_Code folders to find the one for SQL Server 2005 database engine installation and look at the LastUsedSource key in the SourceList.

Open the key and change the location to that location that is listed for the key “PackageName”. e.g. SqlRun_SQL.msi is usually in \Setup folder so you would put C:\Temp\SQL2005CD\Setup\

If there is n;1; then leave it there, just append to the end of that. If there is a NET folder also, open that and change the item 1 to the same source location.

This will now allow the process to run without error.

This entry was posted in Tips. Bookmark the permalink.