DECLARE @Jobname Varchar(50)
DECLARE @Jobid binary(16)

Set @Jobname = N’ESB_LaSalle-Loan-Removal-Monthly’
SELECT @Jobid = job_id FROM msdb.dbo.sysjobs WHERE (name = @Jobname)
select ‘job1’, @jobid, @jobname
IF (@jobId IS NOT NULL)
exec sp_delete_job @job_name=@Jobname;

Tagged with:

Filed under: SQL