T-sql script for Job
USE msdb ;
GO
EXEC dbo.sp_add_job
@job_name = N'ForecastDataJob' ;
GO
EXEC sp_add_jobstep
@job_name = N'ForecastDataJob',
@step_id = 1,
@step_name = N'Generate Weekly Consumption Data',
@subsystem = N'TSQL',
@command = N'EXECUTE Forecast.GenerateWeeklyConsumptionData 106',
@on_success_action = 3,
@on_success_step_id = 2,
@database_name = N'demo-psi-drc.mangoserver.net',
@retry_attempts = 5,
@retry_interval = 10 ;
GO
EXEC sp_add_jobstep
@job_name = N'ForecastDataJob',
@step_id = 2,
@step_name = N'Generate Weekly Forecast Data',
@subsystem = N'TSQL',
@command = N'EXECUTE Forecast.GenerateWeeklyForecastData 106',
@database_name = N'demo-psi-drc.mangoserver.net',
@retry_attempts = 5,
@retry_interval = 10 ;
GO
declare @sid int;
EXEC dbo.sp_add_schedule
@schedule_name = N'ExecuteForecastDataJob',
@freq_type = 4,
@freq_interval = 1,
@active_start_date=20130301,
@active_start_time = 235959,
@schedule_id = @sid out;
select @sid;
EXEC sp_attach_schedule
@job_name = N'ForecastDataJob',
@schedule_id = @sid ;
GO
http://msdn.microsoft.com/en-us/library/ms187320(v=sql.105).aspx
出处:http://jackhuclan.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。