liveBook · Manning

Scheduling engine

As explained in 100 SQL Server Mistakes and How to Avoid Them

A scheduling engine is software that determines when configured jobs should run and coordinates their execution.

A scheduling engine determines which configured jobs are due, runs them against the correct SQL Server instances, and records the results. It centralizes recurring work such as backups and database maintenance instead of relying on manual effort. section 12.4.1 section 9.9

Avoid these common mistakes:

  • Mistake 1—automating only the task: A script that performs maintenance still leaves scheduling, targeting, failure recording, and reporting fragmented. section 12.4.1
  • Mistake 2—building before checking fit: An inventory-backed engine can take months to design, configure, and test, so smaller environments may need a simpler centralized tool. section 12.4.1
  • Mistake 3—leaving maintenance manual: Missed work, staff turnover, and opportunity cost make centralized automation an operational safeguard. section 9.9

Inventory-driven backup scheduling

An inventory database stores servers, instances, permitted credentials, hosted databases, and backup schedules. A SQL Agent job runs a PowerShell script every minute; the script asks which databases are due, connects to the relevant instances, performs backups, and writes success or failure results back centrally. section 12.4.1

Listing 12.2 Retrieving failed backup jobs for all servers
SELECT
     Server
   , name
   , message
   , run_status
FROM (
   SELECT
         Server
       , j.name
       , jh.message
       , jh.run_status
       , ROW_NUMBER() OVER(PARTITION BY Server ORDER BY run_date, run_time DESC) AS RowNumber
   FROM msdb.dbo.sysjobhistory jh
   INNER JOIN msdb.dbo.sysjobs j
       ON j.job_id = jh.job_id
   WHERE jh.run_status = 0
   AND j.name = 'Backups'
) Results
WHERE RowNumber = 1 ;

Use the failed-job query to inspect the latest failed backup result across registered servers and connect scheduling with operational reporting. section 12.4.1

How 100 SQL Server Mistakes and How to Avoid Them covers it

How deep it goes
Explains inventory, due-work selection, execution, result recording, and implementation effort, but defers detailed engine design.
Examples
Uses an inventory-backed backup coordinator and tables, views, and stored procedures for cross-instance maintenance scheduling.
What it assumes
Assumes SQL Server estate administration and automation knowledge while identifying inventory and registration requirements.
What you can do after
Build it from scratch for estate-wide scheduling, or evaluate whether Azure automation and elastic jobs are more suitable.
How it connects
Connects inventory databases, SQL Agent, PowerShell, backups, database maintenance, and centralized management.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of 100 SQL Server Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.