Congratulations to Paul E. Matthews of Centura Banks, Inc. in Rocky Mount, North Carolina, and Shafeek Ashroff of Mynd Corporation in Columbia, South Carolina. Paul won first prize of $100 for the best solution to the September Reader Challenge, "Registry Problems." Shafeek won second prize of $50. Watch SQL Server Magazine UPDATE for next month's Reader Challenge. In the meantime, here's the solution to September's Reader Challenge.

Problem


Chris is generally cautious when working on a production machine, but this time he goofed. In preparing to use the REGEDIT.EXE tool to modify the registry, he accidentally deleted the whole MSSQLServer key (HKEY_LOCAL_MACHINE\SOFTWARE\ Microsoft\MSSQLServer on SQL Server 7.0 and 6.5, HKEY_LOCAL_MACHINE\ SOFTWARE\Microsoft\Microsoft SQL Server on SQL Server 2000). Now SQL Server won't start. Chris needs to get the machine running again as soon as possible. How can he restore the registry entries that SQL Server needs?

Solution


SQL Server doesn't store much information in the registry, but each service is represented (for example, HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Services\MSSQLServer) so that the Service Control Manager can start and stop each service. SQL Server also stores performance-counter information in the registry.

SQL Server and the SQL Server agent share a Registry key containing configuration information that each service reads in the initial phases of each service's startup (this was the key that Chris accidentally deleted). Fortunately for Chris, SQL Server comes with a tool that can rebuild these registry entries. How you use the tool depends on your SQL Server version:

6.5: Run the setup program (from the MSSQL\BINN directory), using the RegistryRebuild parameter:

setup /t RegistryRebuild = On

The setup program will present the same dialog boxes as it does during installation and will rebuild the registry keys based on the information you provide.

7.0: At the end of the installation phase, the setup program executes the regrebld.exe utility, which saves the information in the registry keys to five backup files (*.rbk) in the binn directory. You can later use the regrebld program to either restore the keys or to refresh these backup files. (Note that SQL Server doesn't automatically update these files if you change some configuration value, such as security mode, after installation.) The regrebld program recognizes two command-line parameters: -Backup and -Restore.

2000: SQL Server 2000 works in much the same way as SQL Server 6.5. You run the setup program and choose Advanced Options, Registry Rebuild. The setup program then prompts you for relevant information and creates registry keys accordingly. (The FAQ section in SQL Server 2000 Books Online (BOL) incorrectly specifies that the setup program uses regrebld.exe to perform the registry modifications.)