If the transaction log file for MSDB database is accidentally deleted than follow below steps to rebuild the MSDB database:
- Stop the SQL Server service & 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"C:\SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Install\instmsdb.sql" -o"C:\instmsdb.out"
- Review the instmsdb.out for any errors and re-apply the service packs.
- Stop the SQL Server.
- Start the SQL Server normally.