I had accidentally deleted the transaction log file of msdb database on a newly installed SQL Server 2008 R2 instance yesterday, while I was removing the old tempdb files. Although I normally copy the system database files prior removing the tempdb files from the default location, I missed it this time. When I connect to the instance, I received the following error:
I searched in Books Online and found this article about Rebuilding System Databases, which helps in rebuild the msdb database.
Steps to Follows
- Stop all the SQL Server services & start the command prompt with elevated administrative privilege & execute the following command:
NET START MSSQLSERVER /T3608
- Once you start the SQL Server with trace flag 3608, you will be able to detach the msdb database. To do that, execute the following command in SQLCMD mode:
SQLCMD -E -S DBS03 -dmaster -Q"EXEC sp_detach_db msdb"
- Rename the msdb data file, and execute the instmsdb.sql file from the install folder, as shown below:
SQLCMD -E -S DBS03 -i"E:\SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Install\instmsdb.sql" -o"E:\instmsdb.out"
- Review the instmsdb.out for any errors and re-apply the service packs.
- Stop the SQL Server.
- Start the SQL Server normally
Since I was able to connect to the instance without any error, I stopped the SQL Server instance and copy all the system databases files. Later I restarted the SQL Server Agent and the instance was online.
No comments:
Post a Comment