Update the JobStep\Job Schedule using SQLDMO

  • Hi All,

    I have a SQL Job created for a database and I have done all the necessary settings(Creating a job step and schedule). Now I have to update or modify the Job step and schedule too using SQLDMO.

    For the Jobstep and schedule I have used the JobStep and JobSchedule class. This works fine. But I have not found a way to update an already exsiting jobstep and jobschedule.

    Any hint\help is highly *valued*

    Thanks

    SK

     

     

  • This is a taster of what you need.

    Substitute the relevant values required.

    Care with amending job schedule values using DMO as I have found they need to be amended in a specific order on occassions.

    Paul.

     

    Dim sJob

    Dim sStep

    For Each sJob in oSQLServer.JobServer.Jobs

         'JobSteps

         If sJob.Name = "?Name of Job" Then

                For Each sStep in oSQLServer.JobServer.Jobs(sJob.Name).JobSteps

                'Whatever changes you need to make to job step here

                Next

         End if

      

        'Job Schedules

         If sJob.Name = "?Name of Job" Then

         'Changes here e.g.

         oSQLServer.JobServer.Jobs(sJob.Name).JobSchedules(1).Schedule.FrequencyInterval = ?Value

         End if

    Next

    Paul R Williams.

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

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