Blockquote
只要没有参数就可以工作。– RoastBeast 2015 年 12 月 22 日 17:30
这是带有传递参数的版本
declare @variable -- job name
declare @command -- command
set @command = 'select * from table where data='+@variable
exec msdb..sp_add_job
@job_name =@variable,
@enabled=1,
@start_step_id=1,
@delete_level=1 --Job will delete itself after success
exec msdb..sp_add_jobstep
@job_name=@variable,
@step_id=1,
@step_name='step1',
@command=@command
exec msdb..sp_add_jobserver
@job_name = @variable,
@server_name = 'yourserver'
exec msdb..sp_start_job
@job_name=@variable