Trying to Add Job Schedule Using T-SQL

  • We have several jobs that we run once per month for month end finance closing. At this time we are having to manually enter the schedule for each job every month. In order to save time and minimize mistakes, I would like to add the schedules via T-SQL.

    The problem is, I can add the records, and they show up, but they don't seem to run. Here is the code that I am using:

    INSERT INTO msdb..sysjobschedules

    SELECT 'FCF3AD0F-E9AD-46F8-9598-F6A7BB11845A', '02/03/2012', 1, 1, 0, 0, 0, 0, 0, '20120204', '99991231', '60000', '235959', '20120203', '60000', GETDATE() UNION ALL

    SELECT '09816077-C049-4BA2-8577-80C423FEC016', '02/03/2012', 1, 1, 0, 0, 0, 0, 0, '20120204', '99991231', '60000', '235959', '20120203', '60000', GETDATE()

    Can anyone tell me what I am doing wrong, of if I am even going about it the right way?

    Thanks.

    Steve

  • You shouldn't (and indeed I believe you can't) update system tables directly. Use the stored procedure instead - it's called something like sp_addjobschedule.

    John

  • Ahh. I forgot all about that. Thank you very much.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply