SQL Agent error history

  • Is there a way to capture 2 things, when did the job failed and why did it fail ( capturing error message). I don't have the history available for couple of jobs but do know they have failed before and they were fixed. I want to know why they failed before like by looking at the various errors or failed instances for like a year.

     

  • So you need to go back a year? I would see what there is in msdb.dbo.sysjobhistory

  • year was just an example, I would say as long as I can go back if that is possible. Not more than a  year for sure.

  • If the history isn't available in sysjobhistory you'd have to do something like find old backups of msdb that would have the history and restore them on a test, dev, sandbox or whatever  server (using a different database name) . But for system databases, the server you restore to needs to be the same version, build number as the backup so it can be a bit of a challenge. And then finding the correct older msdb, if it exists...it can all be quite a bit of work.

    Sue

  • Restore old msdb backup(s) to a different db name.  We typically add '_' and the date of the backup to the name.  Something like this:

    RESTORE DATABASE msdb_20190915 FROM DISK = 'x:\full\path\to\backup\folder\msdb.bak' WITH MOVE 'MSDBData' TO 'n:\full\path\of\where\to\put\restored\datafile\MSDBData_20190915.mdf', MOVE 'MSDBLog' TO 'l:\full\path\of\restored\logfile\MSDBLog_20190915.ldf'

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply