Nightly Failed Jobs Report

  • Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/glarsen/failed_jobs.asp

    Gregory A. Larsen, MVP

  • Greg, thats a great idea, wish I had thought of it! Im getting to that point, lots of jobs and lots of email, and beyond that processes that run on various non SQL machines that still have to be monitored. This is a good start. Only question I had was do you need global temp table rather than plain?

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

  • quote:


    Only question I had was do you need global temp table rather than plain?

    Andy


    I have found that xp_sendmail does not like accessing standard temp tables that were created outside of it. I presume that this is caused by xp_sendmail running as a seperate connection, and therefore being unable to access the temp table that the job has created. I find that a similar problem occurs with variables.

    Have you any suggestions as to how this difficulty might be overcome? (or, failing that, a better understanding of what might be causing this?)

    Dave.

  • Dave's explaination is exactly the reason why I used a global temp table.

    Dave I think you are right on regarding a different connection. I think this is because you could be logged on as user "XYZ123", but when you run xp_sendmail it runs under the MSSQLSERVER account to send the mail. Therefore a new connection "must" be established to send the mail.

    -------------------------

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

    Gregory A. Larsen, MVP

  • Greg

    I required a similar solution to monitor failing jobs, but across multiple SQL Servers. I ended up writing a script using SQLDMO to get this done. I don't think you would be able to do this using TSQL unless you used linked servers (which wasn't possible in my environment).

    Good article.

    Regards

    Julian

  • Good Idea. I'm working on retrofitting my report process and other automated DBA process to run from a single server and monitor multple servers. I also am having problems getting it to work across all our servers. Maybe I'll consider re-writing in SQLDMO. Thanks for the tip.....

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

    Gregory A. Larsen, MVP

  • We do a similar thing - check several different servers for failed jobs nightly. We have one job on a master server that queries MSDB on the other servers (yes, we use linked servers). Each step in the job runs the query on a different server and appends the results to a text file. The last step is to mail the text file.

    It's simplistic, but pretty easy to maintain and use. If anyone wants the code, let me know.

    Betsy

    birdies95@hotmail.com

  • If its not too long, post the code here, or you can add to the script library.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

  • We do the same thing with a DTS package that uses an ActiveX script to log into each of our 41 servers and query msdb. The results are written out to our web server so I just need to look at the web page each morning. No linked servers necessary.

  • Looks like lots of good methods to accomplish the samething.

    Betsy - I would like the script that uses the linked servers.

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

    Gregory A. Larsen, MVP

  • Hi

    Dont forget jobs that are "still" running, ie. havent finished from when they where scheduled to run at 1am for example and its now 10am, this is a classic item that is easily skipped by the DBA but can result in major problems.

    Cheers

    Chris


    Chris Kempster
    www.chriskempster.com
    Author of "SQL Server Backup, Recovery & Troubleshooting"
    Author of "SQL Server 2k for the Oracle DBA"

  • Good point. If I add that to the script some day, then I'll make sure I post it.

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

    Gregory A. Larsen, MVP

  • Hi,

    Great scripting, Greg. I am searching for an alternative to using xp_sendmail (we don't use it due to 1 way trust from data warehouse to domain with exchange). Perhaps a version of sp_sendmail that allowed the @query! Hmmm..

  • sorry perhaps i should clarify (since sp_sendmail is in house). Since our datawarehouse domain is seperate and not a trustee of our administration domain, xp_sendmail requires an exchange server (or other MAPI mail server) in the same domain. Thus we created sp_sendmail which doesn't include the @query function so Greg's script requires some tweaking. I'm almost complete with a stored proc that includes the name of the failed job in the subject. We use a DTS package for a weekly failed job report.

  • This is a nice solution if you only want to followup the sql-server-stuff.

    We use HP-openview-managex/HP-OperationsW to followup the nt-eventlogs of our servers. All our jobs report failings to the eventlog.

    Jobi

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

Viewing 15 posts - 1 through 15 (of 18 total)

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