定期执行sql:
EXEC sp_add_job @job_name = 'test'
EXEC sp_add_jobstep @job_name = 'test',
@step_name = 'test_1',
@subsystem = 'TSQL',
@command = 'update yourtable set yourcol=0', /*这是你每次想执行的东西*/
@retry_attempts = 5,
@retry_interval = 5
EXEC sp_add_jobschedule @job_name = 'test',
@name = 'Schedule_test',
@freq_type = 16, -- daily
@freq_interval = 26,
@active_start_time = 10000
定期执行存储过程:
USE msdb
EXEC sp_add_job @job_name = 'test'
EXEC sp_add_jobstep @job_name = 'test',
@step_name = 'test_1',
@subsystem = 'TSQL',
@command = 'exec your_proc', /*这里调用存储过程啊*/
@retry_attempts = 5,
@retry_interval = 5
EXEC sp_add_jobschedule @job_name = 'test',
@name = 'schedule_test',
@database_name = 'yourdbname', ************
@freq_type = 4,
@freq_interval = 1,
@active_start_time = 170900