Rebuild MSDB Database
Rebuilding System Databases, which helps in rebuild the msdb database.
Error :Database 'msdb' cannot be opened ...
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 SRVADMIN03NYC2 -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: location C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Install\instmsdb.sql copy of sql file and place on c:\backup location and run the below command on command prompt: sqlcmd -S SRVADMIN03NYC2 -i C:\backup\instmsdb.sql -o C:\backup\installmsdb.txt
Review the instmsdb.out for any errors and re-apply the service packs.
Stop the SQL Server.
Start the SQL Server normally.