标签:
Maintenance Plan 共有两个Cleanup的Task,Maintenance Cleanup Task 和 History Cleanup Task,这两个Task都能根据File Age 和Info Age 来删除早于一定时间的files。
1,Maintenance Cleanup Task
用于删除Maintenance Plan产生的Report files 和 backup files.
Remove old files related to maintenance plans, including text reports created by maintenance plans and database backup files.
2,History Cleanup Task
用于删除Maintenance Plan产生的Logging 信息。
Discard old historical information from tables in the msdb database. This task supports deleting backup and restore history, SQL Server Agent Job history, and maintenance plan history.
一, Maintenance Cleanup Task
Specify the minimum age of the files that you want to delete by providing a number, and unit of time (Day, Week, Month, or Year). Files older than the time frame specified will be deleted.
通过View T-SQL查看后台的TSQL Script
二,History Cleanup Task
通过View T-SQL查看后台的TSQL Script
declare @dt datetime select @dt = cast(N‘2015-10-25T16:27:22‘ as datetime)
exec msdb.dbo.sp_delete_backuphistory @dt GO
EXEC msdb.dbo.sp_purge_jobhistory @oldest_date=‘2015-10-25T16:27:22‘ GO
EXECUTE msdb..sp_maintplan_delete_log null,null,‘2015-10-25T16:27:22‘
GO
参考文档:
https://msdn.microsoft.com/en-us/library/ms177182(v=sql.110).aspx
https://msdn.microsoft.com/en-us/library/ms186524(v=sql.110).aspx
Maintenance Plan Usage2:Task Usage (Cleanup)
标签:
原文地址:http://www.cnblogs.com/ljhdo/p/5156740.html