sp_sjobcreate

Description

This procedure serves several purposes:�

By default, the @name argument is the name of a scheduled job. To specify the name of a job or a schedule, the @name argument is prefixed with jname or sname.

Syntax

sp_sjobcreate @name=’jsname’, @options=’server, jname, jdesc, jcmd, sname, sdesc, repeats, properties, starttime, enddate, endtime, days, dates’

Parameters

name (jname, sname, sjname)

The name of the new job, schedule, or scheduled job.

NoteWhen you create a name for a job, a schedule, or a scheduled job, the name must begin with a letter. If you create a name beginning with a digit, an error occurs.

option

A list separated by commas of the field names and values you use to create a job, a schedule, or a scheduled job. Values are:

Returns

Examples

Example 1

The following example creates a new job called “find_old_logins” that consists of running a stored procedure:�

sp_sjobcreate @name=’jname=find_old_logins’
@option=’jcmd=”exec sp_find_old_logins”,jproperties=shared’

Example 2

The following example creates a new schedule that becomes valid at 1:00 am and repeats every day:

sp_sjobcreate @name=’sname=daily 01:00am’, 
@option=’repeats=1day,starttime=01:00am,
endtime=02:00am’

Example 3

The following example creates a new scheduled job to run on server “dev1” using the existing job “find_old_logins” and schedule called “daily 01:00am”�

sp_sjobcreate @name=’dev1_old_logins’, 
@option=’server=dev1,jname=find_old_logins, sname=daily 01:00am’

Example 4

The following example creates a new schedule called “evening_sales_report,” using new job called “load_sales_data,” and a new schedule that runs every Monday, Wednesday and Friday at 23:00. The schedule is given a default name based upon the ID value in the schedule table.�

sp_sjobcreate @name=’evening_sales_report’
@option=’server=reports, jname=load_sales_data,�
jcmd=exec sp_new_sales_data,�
starttime=23:00,endtime=23:00,days=Monday:Wednesday:Friday’

Usage