select * into #TempR from
(select ROW_NUMBER()Over(order by j.name)ID, cast(j.name as varchar(40)) Step
from msdb.dbo.sysjobs j
join msdb.dbo.sysjobsteps js on js.job_id = j.job_id
join [ReportServer].[dbo].[Subscriptions] s on js.command like '%' + cast(s.subscriptionid as varchar(40)) + '%'
where s.LastStatus like 'Failure sending mail%')P
declare @min int,@max int
set @min=(select Min(ID) from #TempR)
set @max=(select Max(ID) from #TempR)
--View Jobs List
select * from #TempR
--Execute All Jobs
while(@min<=@max)
begin
declare @var nvarchar(max)
set @var=(select Step from #TempR where ID=@min)
execute msdb.dbo.sp_start_job @var
print @var
set @min=@min+1
end
drop table #TempR
(select ROW_NUMBER()Over(order by j.name)ID, cast(j.name as varchar(40)) Step
from msdb.dbo.sysjobs j
join msdb.dbo.sysjobsteps js on js.job_id = j.job_id
join [ReportServer].[dbo].[Subscriptions] s on js.command like '%' + cast(s.subscriptionid as varchar(40)) + '%'
where s.LastStatus like 'Failure sending mail%')P
declare @min int,@max int
set @min=(select Min(ID) from #TempR)
set @max=(select Max(ID) from #TempR)
--View Jobs List
select * from #TempR
--Execute All Jobs
while(@min<=@max)
begin
declare @var nvarchar(max)
set @var=(select Step from #TempR where ID=@min)
execute msdb.dbo.sp_start_job @var
print @var
set @min=@min+1
end
drop table #TempR
No comments:
Post a Comment