A query that deletes the log entries that are older than the last 10 runs.
Since some packages may run several times a day, and some run once few days, I want to keep
history of the latest 10 runs. Here is what I came up with that deletes the log entries for a
DTS package name provided. I would like to modify this for all the DTS packages. Is there any
way to accomplish this without a cursor?
DELETE FROM sysdtspackagelog
WHERE NAME = @PackageName AND endtime <
(SELECT MIN (endtime)
FROM
(SELECT TOP 10 * FROM sysdtspackagelog
WHERE NAME = @PackageName
ORDER BY endtime DESC ) AS B )
Thanks.