lovesan

lovesan

日常分享,各种优惠,服务器,编程,运维等

Resolving the large space usage of the MSDB database in SQL SERVER

Sometimes you may encounter the MSDB database in SQL SERVER occupying a large amount of disk space, leading to a full disk. The following methods can be used for cleanup.
The likely reason is that the backup logs are too large.

Note: Please make sure you know what you are doing before cleaning up.#

Only execute the cleanup if you are certain that the backup logs are useless; this operation cannot be undone.#

truncate table backupfile;
truncate table backupfilegroup;
truncate table restorefile;
truncate table restorefilegroup;
truncate table restorehistory;
truncate table backupset;
truncate table backupmediafamily;
truncate table backupmediaset;

If logging is not needed, you can disable logging with the following command.#

dbcc traceon(3226,-1)

The cleanup is now complete. If the database has not shrunk, you can shrink it; generally, it will shrink automatically.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.