SQL Server monitors job execution

Source: Internet
Author: User
Recently, some jobs in the database cannot be executed very healthily. However, it is very troublesome to log on to the DB server to view error logs during monitoring, and jobs are generally important, for example, back up a database or clear a database. On the website side, it is often because the cleanup job cannot be normally executed, resulting in a database space increase of 2G-3G in a few days. Finally, the troubleshooting found that, it is because the execution of the cleaned SQL statement times out. Therefore, a job execution report function is provided, which is integrated into the company's background and put together with error logs to facilitate daily monitoring.

The following are the SQL statements used:

 
Select top 150. run_date,. run_time, B. name, step_id, step_name,. message,. run_status,. run_duration from MSDB. DBO. sysjobhistory A, MSDB. DBO. sysjobs B where. job_id = B. job_id and name not in ('job _ exclude ') and. step_id> 0 order by run_date DESC

This function mainly uses two job system tables: MSDB. DBO. sysjobhistory and MSDB. DBO. sysjobs.

Job_exclude: it is a job that runs very frequently and can be excluded, for example, once every 5 minutes. Monitoring does not make much sense.

The following is a function diagram:

In fact, there are more and better ways to maintain the database. Later, we will consider using web pages to monitor database health information, such as disk space usage, this can be closely linked with the internal background for easy monitoring

I hope it will help you. Please click here for more suggestions. Thank you.

RelatedArticle:

SQL Server System Table analysis (1)-Backup table

SQL Server monitors job execution

Find yourself-2011/04/18-. net, C #, ASP. NET-starter blog

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.