Why does the generated SQL Agent job script include @schedule_uid in the section adding the job schedule?

Bob Sovers 1 Reputation point
2021-08-11T21:50:02.673+00:00

The task to generate a script for an existing SQL Agent Job has been around for a very long time. And yet, even now, the generated script needs to be edited to eliminate the @schedule_uid... line (and the preceding line's ending ",". Otherwise it may try and use an existing schedule.

There are numerous articles discussing this issue, and all just end with "delete the line". There are even several posts on how to search for and delete the offending lines. Again, this is exacerbated by the issue of having to also delete the "," that ends the preceding line.

And yet, no request that I have found asks Microsoft to either allow this parameter to be selected (or deselected) in the scripting options, or better yet, just eliminated altogether.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,361 questions
SQL Server Migration Assistant
SQL Server Migration Assistant
A Microsoft tool designed to automate database migration to SQL Server from Access, DB2, MySQL, Oracle, and SAP ASE.
517 questions
{count} votes

2 answers

Sort by: Most helpful
  1. AmeliaGu-MSFT 13,971 Reputation points Microsoft Vendor
    2021-08-12T03:18:54.39+00:00

    Hi BobSovers-5969,

    Welcome to Microsoft Q&A.
    If a schedule has been created in the job, the unique identifier for the schedule and the content of the schedule will be automatically included when generating the script. And we have to remove the script about msdb.dbo.sp_add_jobschedule, otherwise, the schedule will still exist in the new job generated by the generated script, even if we delete schedule_uid.

    If this issue bothers you, I recommend you submit it to the Microsoft feedback at this link https://feedback.azure.com/forums/908035-sql-server. Your feedback is valuable for Microsoft to improve the level of products and service. Appreciate for your understanding.

    Best Regards,
    Amelia


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. AmeliaGu-MSFT 13,971 Reputation points Microsoft Vendor
    2021-08-13T07:44:19.277+00:00

    Hi BobSovers-5969,

    Thanks for your reply.
    @schedule_uid, as a output para of msdb.dbo.sp_add_jobschedule by desgin, cannot be eliminated automatically when generating the script.
    We can eliminate the @schedule_uid and the preceding ",", or change a few characters in the schedule_uid currently.
    Sorry for any inconvenience. You can submit this issue to Microsoft feedback above.

    Best Regards,
    Amelia