sp_send_dbmail - Job Runtime

  • I have two steps in each of my SQL Agent jobs - one called if a job step fails, another if it succeeds.

    Each step utilizes sp_send_dbmail to send an email notification.

    On the successful completion step, I would like to include the job's total run-time in the body of the email sent.

    How can I determine total run-time (or more accurately current run-time) for the job and send via sp_send_dbmail in the body of the email?

    Thanks.

  • I believe you should be able to query the msdb tables for the information you need.

    Maybe this article http://www.bidn.com/blogs/DevinKnight/ssis/2792/identifying-long-running-sql-agent-jobs-script could help you along the way.

Viewing 2 posts - 1 through 1 (of 1 total)

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