When I scripted out the “DROP and CREATE” options (on SQL2008R2) for a SQL job I found it only worked once as it created a GUID that fails next time it runs (as it already existed).
To fix this I replaced [@job_id=N’blah blah blah’] in [sp_delete_job] with [@job_name=N’blah blah’] including the actual job name pasted from [sp_add_job].
Also I modified the script to work in additionally with SQL 2000 and SQL 2005 by …
– in [sp_delete_job] commenting out [–, @delete_unused_schedule=1]
– duplicating [sp_add_job] with the first one proceeded by [IF @@version LIKE ‘%2000%’; BEGIN] and no [@notify_email_operator_name]
– and the second one proceeded by [END; ELSE]