Search This Blog

Saturday, August 18, 2007

Rebuild Database Utility

First lets look at cases of when Rebuild Utility needs to be used by a SQL Administrator

These are the 3 cases
(i) Master database files are corrupt or not available
(ii) When the default collation need to be changed
(iii) Model database files are corrupt or not available

Now lets go in detail on what are the steps to use these and what happens internally when we rebuild the database.

In SQL 2000 we use Rebuildm.exe which is present in bin directory to start the rebuild process.
The basic parameters provided are the:
  1. SQL Server Instance Name,
  2. Source Directory(i.e. Network Path or CD from which SQL Server is installed),
  3. Collation Settings(Default is Dictionary Order, case-insensitive for use with the 1252 Character Set)
Now what happens internally is .mdf & .ldf files of master,model,msdb,tempdb are copied to the data files drive.And also you could see a series of script run after the copy,so needless to say that if you copy these files manually to the data files path SQL Server will still start but not receomended as those scripts are not run when you copy the same manually.

In SQL 2005 , rebuildm is changed to term called as REBUILDDATABASE and again it has the above 3 paramters implemented in a slighlyly different way.

start /wait setup.exe /qn INSTANCENAME= REINSTALL=SQL_Engine REBUILDDATABASE=1 SAPWD= SQLCOLLATION=

Instead of specifying the Source Directory path we map drive the same to the local server and
then start the SQL Server Setup again with REBUILDDATABASE=1 option.Also if you dont specify that SQLCollation parameter then the default collation is used.

No comments: