Maintenance Plan Usage2:Task Usage (Cleanup)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Maintenance Plan Usage2:Task Usage (Cleanup)相关的知识,希望对你有一定的参考价值。

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)的主要内容,如果未能解决你的问题,请参考以下文章

Maintenance Plan Usage4:Check Integrity and Shrink database

DAC Usage2:通过Extract,Register 和 Upgrade DAC,实现DB Schema的Migration

预约系统 数据库设计

SqlServer存储过程

MySQL Error: PROCEDURE xmdk.query_all_plan can't return a result set in the given context

G - Eating Plan