SQL Agent Jobs


SQL Agent Jobs
Azure Automation Service
Elastic Jobs
Automated Tuning
Automated Patching
Start course
1h 1m

Whether you’re running SQL Server on-premise, in a VM, on a managed instance, or using Azure SQL, there is maintenance to be performed and other tasks that need to be executed on a regular basis. In this course, we will look at the options available to you in these various environments for automating maintenance and regularly repeated tasks.

SQL Server has a long history of task automation through SQL Server agent, not only will we see how to use it but also how it’s been adapted to carry out maintenance tasks, and how similar functionality has made it into Azure services. From mundane single-database scheduled backups through to task and performance automation across multiple servers, this course looks at on-premise and in-cloud options.

If you have any feedback relating to this course, feel free to contact us at support@cloudacademy.com.

Learning Objectives

  • Maintain your databases and data through the use of maintenance plans and the SQL Server Maintenance Wizard
  • Use SQL Agent Jobs to automate maintenance tasks
  • Automate maintenance across multiple SQL servers
  • Set up rules to enforce policies
  • Back up your SQL Server instances using Azure Recovery Services Vault
  • Learn about the Azure Automation Service and how it can be used
  • Use Elastic Jobs to schedule tasks within the context of databases
  • Manage database performance with Automated Tuning
  • Manage database updates with Automated Patching

Intended Audience

  • Data engineers
  • Database engineers
  • IT professionals or anyone looking to learn about automating tasks in Azure SQL and SQL server


To get the most out of this course, you should have experience with SQL Server Management Studio, be familiar with reading and writing SQL, and have an understanding of basic database architecture and administration tasks, like indexes and backups.


Course Related SQL Scripts



As we have seen Maintenance Plans have predefined maintenance tasks, that allow you to quickly and easily set up a job. You could think of them as specifically templated SQL Agent jobs. I now want to look at using SQL jobs to automate tasks. There is no reason you couldn't automate backups and index rebuilds with a scheduled job, but as we've already covered that with Maintenance Plans, I'm going to look at automating a routine and regular non-administrative task.

An SQL Agent job can have multiple steps. The steps can be SQL statements including calling stored procedures, they can be SSIS packages, or you could execute operating system commands or scripts via xp_commandshell. A job can have multiple schedules. For instance, a customer usually sends orders to be processed between eight and 10 every morning. Timeliness of order processing is important. So you might schedule the job to run every five minutes between those morning hours.

On occasion, customers may send additional orders through on a Friday afternoon. To accommodate that, you create another schedule that runs every 15 minutes, from one to 4:00 p.m on a Friday. You can also notify an operator of the outcome of the job whether that is just on its completion, failure, or success. Next, I want to show you creating a job, that will import a CSV file, and will notify an operator if it fails, but also emails other staff on its completion with details of the imported data.

About the Author
Learning Paths

Hallam is a software architect with over 20 years experience across a wide range of industries. He began his software career as a  Delphi/Interbase disciple but changed his allegiance to Microsoft with its deep and broad ecosystem. While Hallam has designed and crafted custom software utilizing web, mobile and desktop technologies, good quality reliable data is the key to a successful solution. The challenge of quickly turning data into useful information for digestion by humans and machines has led Hallam to specialize in database design and process automation. Showing customers how leverage new technology to change and improve their business processes is one of the key drivers keeping Hallam coming back to the keyboard.