Creating a regularly scheduled job in SQL

The goal of this post is to show how you can create a schedule and attach an existing job to that schedule.

Create a schedule on an existing job (or create a job as described in a number of previous posts).

1) Open SQL Server Manament Studio (SSMS), connect to SQL Server, and right click on the Sql Server Agent \ Jobs \ Your Job.
Select Properties and click.1

2) Click on the Schedules Page on the left, then click New… under Schedule list.

If the job already has a schedule, you can edit it or remove it.
2

 

3) Enter a name for the schedule, then select the type of schedule you want.
Here is some information:
Schedule Type: the option are straightforward. For “Start whenever the CPUs become idle” you need to set up an idle CPU condition (see http://msdn.microsoft.com/en-us/library/ms189065.aspx)
Enabled: here you can disable a schedule without deleting it.
You can select what type of occurrence, the days of the week and/or how many days/weeks/months to skip between executions.
For daily schedules, you can specify how many seconds/minutes or hours between executions.
Note: By default, Sql Agent will not execute a job more often than four times a minute (every 15 seconds). In general, the scheduler cannot be used for “real time” events. The job start can be delayed depending on the system load.
3

 

Check that the next job execution will be triggered at the right time.

After creating or updating a schedule, you can check the next execution date and time.
Preconditions: Sql Agent has to be running for the next execution date/time to be calculated.
In SSMS, expand the Sql Server Agent node under Object Explorer, then double-click on Job Activity Monitor. Look for your job name and check the column “Next Run”.
4

Check the job was executed at the right time after the scheduled time has passed.

You can check the job history at any time to confirm that the schedule was triggered correctly and the job succeeded.
Just right click on the job and select “View History”.
5

0 comments:

Post a Comment