Job Scheduler provides a concise set of stored procedures for working with scheduled jobs. Their names are prefixed with sp_sjob, where sjob is an abbreviation for scheduled job.
The stored procedures for creating jobs, schedules, and scheduled jobs will use the server user name to record the owner. The suser_name system function will be used to obtain this.The stored procedures also support working with the underlying job and schedule objects, and provide an interface to control scheduled jobs that are currently running and manage the history and job output that they produce.
The stored procedures accept a name or ID argument, which specifies the object they should operate on. Stored procedures that operate on several different objects, such as a job, a schedule, or a scheduled job, accept a prefix to the name or ID argument, which specifies the sort of object the name or ID refers to: for schedules – @sname; for jobs – @jname.
The following is an example of @sname:
@name= ‘sname=daily_schedule’
The following is an example of using @jname:
@name= ‘jname=run_update_stats’
The name or ID default is to reference a scheduled job.
Command names, command keywords, the word “null”, data items, and statistic types are not case sensitive. File names, view names, and other user-supplied names are case sensitive.
If a parameter value contains embedded spaces (such as those in data items, statistic types, and date-time specifications), you must surround the value with quotes. Matched pairs of single-quote or double-quotes are valid delimiters.
If the parameter value contains an embedded quote that is the same as the character used to delimit the entire value, supply a pair of the quotes within the parameter value. Job Scheduler compresses the pair of quotes to a single character.
The word “null” within quotes is not considered a keyword.
You can enter Job Scheduler commands on multiple lines.