Shrink msdb database SQL Server
Steps to shrink msdb database in SQL Server 2005:
- T-SQL: truncate table msdb.dbo.log_shipping_monitor_history_detail
- T-SQL: exec msdb.dbo.sp_purge_jobhistory @oldest_date='2013-02-07T13:55:10'
(change date above as required) - T-SQL: alter index all on msdb.dbo.sysjobhistory reorganize
- Management Studio: system databases > msdb > tasks > shrink > database
OR, same thing in T-SQL: dbcc shrinkdatabase('msdb')
To see disk usage for a database:
- Management Studio: system databases > msdb > Reports > Standard Reports > Disk Usage
I tried this and the MSDB (.mdf) is still the same size, I wonder do I need to Alter database file in order to reduce the size?