Skip to content

Instantly share code, notes, and snippets.

@matt40k
Created January 4, 2016 12:31
Show Gist options
  • Save matt40k/e65bbfb65c69a6291aba to your computer and use it in GitHub Desktop.
Save matt40k/e65bbfb65c69a6291aba to your computer and use it in GitHub Desktop.
Create schedules for SQL job
USE [msdb]
GO
DECLARE @schedule_id int
EXEC msdb.dbo.sp_add_jobschedule @job_id=N'd938409a-2ffb-4b7c-8bd6-8cf3dc557300', @name=N'One-Time',
@enabled=1,
@freq_type=1,
@freq_interval=1,
@freq_subday_type=0,
@freq_subday_interval=0,
@freq_relative_interval=0,
@freq_recurrence_factor=1,
@active_start_date=20160104,
@active_end_date=99991231,
@active_start_time=230000,
@active_end_time=235959, @schedule_id = @schedule_id OUTPUT
select @schedule_id
GO
USE [msdb]
GO
DECLARE @schedule_id int
EXEC msdb.dbo.sp_add_jobschedule @job_id=N'd938409a-2ffb-4b7c-8bd6-8cf3dc557300', @name=N'Weekly',
@enabled=1,
@freq_type=8,
@freq_interval=1,
@freq_subday_type=1,
@freq_subday_interval=0,
@freq_relative_interval=0,
@freq_recurrence_factor=1,
@active_start_date=20160104,
@active_end_date=99991231,
@active_start_time=0,
@active_end_time=235959, @schedule_id = @schedule_id OUTPUT
select @schedule_id
GO
USE [msdb]
GO
DECLARE @schedule_id int
EXEC msdb.dbo.sp_add_jobschedule @job_id=N'd938409a-2ffb-4b7c-8bd6-8cf3dc557300', @name=N'Daily',
@enabled=1,
@freq_type=8,
@freq_interval=61,
@freq_subday_type=1,
@freq_subday_interval=0,
@freq_relative_interval=0,
@freq_recurrence_factor=1,
@active_start_date=20160104,
@active_end_date=99991231,
@active_start_time=0,
@active_end_time=235959, @schedule_id = @schedule_id OUTPUT
select @schedule_id
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment