Making a copy of a Server Agent Job

  • Hi

    What's the safest way to create a copy of a job (bit like cut and paste; appreciate it's not that simple)

    I'd like to archive an old job (as a copy) before making changes to the original

    I can find useful info on moving jobs between servers

    Can't find anything useful regarding copying on the same server

    Thanks

    - Damian

  • Damian

    Just right-click on the job in SSMS, choose Script Job As and use one of the options to generate the script.

    John

  • Script the job, put the script into source control.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thanks, that is pretty simple!

    How does it handle schedules

    I see it generates a schedule using @schedule_uid with a uniqueidentifier

    If I script out the job, change the name and run it, it reproduces the exact same @schedule_uid value for the new job

    Is this correct?

    If I change the new schedule, it changes the old schedule

    looks like commenting out the schedule id works as it just generates a new one

    I'm there with this now, thanks!

    - Damian

  • DamianC (12/19/2016)


    Thanks, that is pretty simple!

    How does it handle schedules

    I see it generates a schedule using @schedule_uid with a uniqueidentifier

    If I script out the job, change the name and run it, it reproduces the exact same @schedule_uid value for the new job

    Is this correct?

    If I change the new schedule, it changes the old schedule

    looks like commenting out the schedule id works as it just generates a new one

    I'm there with this now, thanks!

    Schedules are linked to jobs (or vice versa, as they have a Many to Many relationship) , so yes, this would be expected. You're effectively assigning a new job to the same schedule. This would mean if you amend the schedule on one job, it'll amend the other, as they are indeed, the same schedule.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

Viewing 5 posts - 1 through 4 (of 4 total)

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