The Generate Script for sp_purge_jobhistory!
I have created a small script for generating sp_purge_jobhistory for my SQL jobs at work. The first part of script generate system store procedure for purge history of jobs where is condition (WHERE sjs.next_run_date = CONVERT(VARCHAR(10), DATEADD(dd, 0, @v),112)) - that means select all sql jobs which runs very often!
Script is below:
Result looks like this.
(click the picture)
Here is second part of the script.
See you next time!