Vous êtes ici :
Le nettoyage des tables d’historiques de msdb, à effectuer périodiquement.
Nettoyage des historiques
Transact-SQL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
/*------------------------------------------------------------------- [SCRIPT] Nettoyage des historiques [DATABASE] msdb [DESCRIPTION] backups, jobs, mail, plans de maintenance [MAJ PAR] DATAFLY - Arian Papillon [DATEMAJ] 17 mars 2021 -------------------------------------------------------------------*/ USE msdb GO -- Backup history cleanup DECLARE @DeleteBefore datetime SET @DeleteBefore = DATEADD(dd,-30,GETDATE()) EXECUTE dbo.sp_delete_backuphistory @oldest_date = @DeleteBefore GO -- Job history cleanup DECLARE @DeleteBefore datetime SET @DeleteBefore = DATEADD(dd,-30,GETDATE()) EXECUTE dbo.sp_purge_jobhistory @oldest_date = @DeleteBefore GO -- database mail cleanup DECLARE @DeleteBefore DateTime SET @DeleteBefore = (Select DATEADD(d,-30, GETDATE())) EXEC dbo.sysmail_delete_mailitems_sp @sent_before = @DeleteBefore EXEC dbo.sysmail_delete_log_sp @logged_before = @DeleteBefore GO -- maintenance plans cleanup DECLARE @DeleteBefore DateTime SET @DeleteBefore = (Select DATEADD(d,-30, GETDATE())) EXEC dbo.sp_maintplan_delete_log null,null,@DeleteBefore |
Table of Contents