

Review the instmsdb.out for any errors and re-apply the service packs.SQLCMD -E -S DBS03 -i"E:\SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Install\instmsdb.sql" -o"E:\instmsdb.out" Rename the msdb data file, and execute the instmsdb.sql file from the install folder, as shown below:.SQLCMD -E -S DBS03 -dmaster -Q"EXEC sp_detach_db msdb" To do that, execute the following command in SQLCMD mode: Once you start the SQL Server with trace flag 3608, you will be able to detach the msdb database.Stop all the SQL Server services & start the command prompt with elevated administrative privilege & execute the following command:.I searched in Books Online and found this article about Rebuilding System Databases, which helps in rebuild the msdb database. When I connect to the instance, I received the following error:

Although I normally copy the system database files prior removing the tempdb files from the default location, I missed it this time. 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.
