2019-07-03

TSQL - Delete a job if it exists


IF EXISTS(
       SELECT 1
       FROM [msdb].[dbo].[sysjobs] a WITH(NOLOCK)
    WHERE a.Name = 'JOB_NAME_HERE'
)
       EXEC sp_delete_job @job_name='JOB_NAME_HERE', @delete_unused_schedule=1;


No comments:

Post a Comment