1 2 3 4 5 6 7 8 9 10 11 12 13 14
| select @jobname = jobname from inserted where numero = @numero
if exists (select * from tempdb.information_schema.tables where table_name like '#tmppp%')
drop table #tmppp
CREATE TABLE #tmppp (id uniqueidentifier, serv nvarchar(30), nom sysname, enabl tinyint, descript nvarchar(512), start_step_id int, category sysname, owne sysname, notify_lev int, notify_em int, notify_ne int, notify_pa int, notify_emop sysname, notify_neop sysname, notify_paop sysname, delet int, datecre datetime, datemod datetime, version int, lastrun int, lastrunt int, lastrunout int, next_run int, next_runt int, next_runs int, current_exec_status int, current_exec_step sysname, current_retry int, has_step int, has_sched int, has_target int, type int)
INSERT INTO #tmppp
EXEC msdb.dbo.sp_help_job @job_name = @jobname, @job_aspect = 'job'
if((select current_exec_status from #tmppp) in (1,2,7))
exec msdb.dbo.sp_stop_job @job_name = @jobname
if exists (select * from tempdb.information_schema.tables where table_name like '#tmppp%')
drop table #tmppp
exec msdb.dbo.sp_update_job @job_name = @jobname
, @enabled = 0 |
Partager