When scripting out jobs using ssms (sql server management studio) the default script for a drop statement is to drop the job according to it’s job_id. This is not beneficial however when pushing code to different environments. Job_id’s are specific to the windows environment in which they are created. To get around this is easy however, you simply need to pass the @job_name parameter to the sp_delete_job stored procedure.
IF EXISTS (SELECT job_id FROM msdb.dbo.sysjobs_view WHERE name = N'jobnamegoeshere') EXEC sp_delete_job @job_name = N'jobnamegoeshere' , @delete_unused_schedule=1
Popular search terms:

After Run Error :
Server: Msg 14274, Level 16, State 1, Procedure sp_delete_job, Line 86
Cannot add, update, or delete a job (or its steps or schedules) that originated from an MSX server.
Thanks for help me.
Very helpful.
Thanks for the information.. Nice.