Create and Schedule a Job in SQL Server

Introduction

In this article, you will learn how to create a new job and schedule that job for execution in SQL Server.

What is a SQL Job? A job is a specified series of actions that an SQL Server Agent performs. Use jobs to define an administrative task that can be run one or more times and monitored for success or failure. A job can run on one local server or on multiple remote servers. Some examples of SQL Jobs are automatic weekly backup, sending auto emails, newsletters, writing log files, and audit logs. 

Getting Started

First of all, start SQL Server 2008 Management Studio. Expand the Databases node and select a database you want to use to create and schedule a job from. 

Create-and-schedule-a-job-in-SQL-Server1.jpg


Create a Job in SQL

For this database, I am going to create a job and schedule that job.

Now click on SQL Server Agent and select "Jobs" and right-click and click on "New Job".

Create-and-schedule-a-job-in-SQL-Server2.jpg

As you can see there are many steps, so let's go one by one. First, provide a job name and description and click "OK". 

General Tab

Create-and-schedule-a-job-in-SQL-Server3.jpg

Now click on "Next". The step name is Steps and provides a name, type and select database and write a command to save in a location and click "OK". 

Steps Tab 

Create-and-schedule-a-job-in-SQL-Server4.jpg

Now click on the "Schedules" tab and provide name, type, frequency, and click "OK". 

Schedules Tab 

Create-and-schedule-a-job-in-SQL-Server5.jpg

Now click on the alerts tab and click on the "Add" button and provide the alert name, type, database name, and click "Ok". 

Alerts Tab 

Create-and-schedule-a-job-in-SQL-Server6.jpg

Now click on the notifications tab and select how you want notifications. 

Notifications Tab 

Create-and-schedule-a-job-in-SQL-Server7.jpg

The final tab is the "Targets" tab which shows you the options of the target server, you can also select multiple target servers. 

Targets Tab 

Create-and-schedule-a-job-in-SQL-Server8.jpg

Summary 

In this article, we learned how to set up and schedule a job in SQL Server. 


Recommended Ebook

Basic SQL Queries

Download Now!
Similar Articles