0

Looking for a crazy script to run after database backup ...

Want to look at all agent jobs and if modified date is equal to today save it to a shared drive, if not skip. Also want to delete the oldest saved file if there are more than five. Any help on any step would be greatly appreciated!

2
  • 1
    Please post what you have so far, then someone can help to optimize. Commented Jan 9, 2020 at 14:55
  • 1
    Welcome to Database Administrators. Please, check the How do I ask a good question? instructions to avoid being downvoted.
    – Ronaldo
    Commented Jan 9, 2020 at 15:24

1 Answer 1

0

A couple of suggestions:

  1. Don't ask us to write an entire system for you. It's probably ok if you have a particular problem with how some script operates, as long as it's DBMS related.

  2. Realize that all SQL Server Agent Jobs are stored in the msdb system database. In order to "save" jobs you could simply take a backup of the msdb database daily. You should do that anyway, since there is a lot of useful history, etc, stored in there.

  3. If you really need to "script" out the jobs, they're stored in msdb in the dbo.sysjobs and dbo.sysjobsteps tables.

1
  • Ok thank you. I will add the code ii have so far and rewrite the question
    – Kmadden1
    Commented Jan 10, 2020 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.