Defines an interface for controlling running jobs.�
sp_sjobcontrol @name=’...’, @option=’...’
The name or ID of the scheduled job, a job, or a runid to be controlled. �
Specifies a comma-separated list of options and option_name=option_value pairs that define the action to perform.
terminate – terminates instances of the job with the given name, ID, or runid.
enable – enables instances of the scheduled job with the given name or ID.
disable – disables instances of the scheduled job with the given name or ID. Any currently running jobs are unaffected.
run_now – schedules the job with the given name or ID to run now.
all_users – allows users with the role js_admin_role to administer scheduled jobs owned by other users.
start_js – starts Job Scheduler.
stop_js – stops Job Scheduler and terminates any running jobs.
stop_js_wait – waits for running jobs to complete, and then stops Job Scheduler.
stop_js_timeout=minutes – waits a specified number of minutes, and then stops Job Scheduler, terminating any running jobs.
Returns 0 for success or an error code.
The following example requests the JS Task and JS Agent to terminate the running job with runid 1532:�
sp_sjobcontrol @name=’runid=1532’, @option=’terminate’
The following example marks the scheduled job called “svr1_load_sales_data” so that it can be run now. The existing schedule is unchanged.
sp_sjobcontrol @name=’svr1_load_sales_data’, @option=’run_now’
The following example disables all of the caller’s scheduled jobs that use the job called “check_user_logins”.
sp_sjobcontrol @name=’jname=check_user_logins’, @option=’disable’
�By default, @name is the name,
the ID, or a scheduled job. To specify
the name or ID of a job or as a runid,
the @name argument is prefixed with jname
or runid
.