码迷,mamicode.com
首页 > 其他好文 > 详细

Maintenance Plan Usage2:Task Usage (Cleanup)

时间:2016-01-25 18:49:16      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:

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(N2015-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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!