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.

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 …

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

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.

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

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.

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.

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

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

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

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

Menu
Exit mobile version