How to Schedule a Job in SQL Server? – Interview Question of the Week #160

Question: How to Schedule a Job on SQL Server?

Answer: A very old and widespread question, keep on coming back to in interviews. Let us see how to schedule a job on SQL Server.

How to Schedule a Job in SQL Server? - Interview Question of the Week #160 sqlserveragent

The first condition to schedule a job in SQL Server is to make sure that your SQL Server Agent is on. If your SQL Server Agent service is not running, your scheduled job will not run.

Let us see the series of examples how we can schedule a job in SQL Server.

Right click on SQL Server Agent >> New >> Job …

How to Schedule a Job in SQL Server? - Interview Question of the Week #160 sqlserveragent1

On the general tab enter the name of the job and click on OK.

How to Schedule a Job in SQL Server? - Interview Question of the Week #160 sqlserveragent2

After right that we will have to configure all the necessary steps in the order to execute the job. We will click on the New once we are on the Steps page.

How to Schedule a Job in SQL Server? - Interview Question of the Week #160 sqlserveragent3

Over here, give the name of the step and select the proper Type for the job and enter the Command.

How to Schedule a Job in SQL Server? - Interview Question of the Week #160 sqlserveragent4

Once you schedule your first step, you can also add more steps to this job as well. Once you add all the steps in your job, you can go to next page Schedules.

How to Schedule a Job in SQL Server? - Interview Question of the Week #160 sqlserveragent5

Once you click on New, you will see the following screen. On this screen, you can configure your schedule for the job. You can select daily, weekly or even monthly schedule over here.

How to Schedule a Job in SQL Server? - Interview Question of the Week #160 sqlserveragent6

Right after that, you can also configure the optional steps of Alerts, Notifications, and Targets. However, they are not mandatory steps.

That’s it. You are technically done scheduling the job on SQL Server.

If you want to test your job, you can right click on it and select the option “Start Job at Step…“. Over here either you can select the steps

How to Schedule a Job in SQL Server? - Interview Question of the Week #160 sqlserveragent7

If you have only one step, your job will just start to run.

How to Schedule a Job in SQL Server? - Interview Question of the Week #160 sqlserveragent8

Once your job is completed, you will see a Success screen.

Reference: Pinal Dave (https://blog.sqlauthority.com)

SQL Jobs, SQL Server, SQL Server Agent, SQL Utility
Previous Post
How Does TOP WITH TIES Work in SQL Server? – Interview Question of the Week #159
Next Post
How to Get VLF Count and Size in SQL Server? – Interview Question of the Week #161

Related Posts

Leave a Reply