The cleanup Task in Maintenance Plans doesn't delete silently reports of maintenance report.
When created normally, the 2<sup>nd</sup> parameter of xp_delete_file points to the \LOG folder and when executing the plan/task, it runs successfully, but w/o deleting any txt files qualifying for deletion.
You only get a somewhat useful error message, when you call xp_delete_file with a real report file of a Maintenance Plan (and a qualifying deletion date!):
Error 22049:
Error executing xp_delete_file extended stored procedure: Specified file is not a Maintenance Plan report file.
Can anybody confirm/deny this behavior in an English installation or another language?
Notes:
- I had only a chance to test this on various German SQL Server installations. If this issue was introduced by localization it may work in an US English installation. Feedback welcome!
- This scenario also fails in German SP3 for SQL 2012, but it works fine in a German SQL 2014
Steps to reproduce:
- Create a Maintenance Plan with a little dummy task (runtime < 1 min.) on a small DB. E.g. Running "DBCC CheckDB" w/o index on MSDB. Schedule this plan to run every minute
- Note that the report files will start to fill your \LOG folder after some minutes
- Create a 2<sup>nd</sup> Maintenance Plan with a Cleanup Task, that deletes Maintenance Plan report files from your \LOG folder, which are older than 1 hour and schedule it to run every 5 minutes
- Wait some hours and you'll see that no Maintenance Plan report file gets deleted!
- To get error 22049, you need to change the Maintenance Plan to delete only a specific report file which is older than 1 hour