question

BobSovers-5969 avatar image
0 Votes"
BobSovers-5969 asked AmeliaGu-msft commented

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

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-generalsql-server-migration
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi BobSovers-5969,
Did the answers help you?
Please feel free to let us know if you have any other question.
If you find any post in the thread is helpful, you could kindly accept it as answer.
Best Regards,
Amelia

0 Votes 0 ·
AmeliaGu-msft avatar image
0 Votes"
AmeliaGu-msft answered AmeliaGu-msft commented

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

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Amelia --

You are correct, @shedule_uid is an OUTPUT parameter of the call to msdb.dbo.sp_add_jobschedule, but in the generated script, it is just specified as an INPUT parameter.

I would not have an issue if it was just an output of the call.

0 Votes 0 ·

Hi BobSovers-5969,

Thanks for your reply.
If the replies could help you, please mark the useful reply as answer to help other community members find the helpful reply quickly.
If you have any other question, please feel free to let us know.

Best Regards,
Amelia

0 Votes 0 ·
AmeliaGu-msft avatar image
0 Votes"
AmeliaGu-msft answered TomPhillips-1744 commented

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

But the entire script will still work fine if the @Schedule_uid parameter is not included. I am only asking that a scripting option be made available to eliminate the generation of this field.

The unique identifier for the schedule is not a required piece of information, and must be deleted out of the generated script to make it useable. Further, its position at the end of the parameters required further scripting "gymnastics" to delete it because the preceding "," must also be deleted.

0 Votes 0 ·

Why do you feel the need to delete it? The only reason you would need to delete it is if the schedule already exists.

0 Votes 0 ·