i stored list of jobs in temp table and that need to be killed.
use msdb
declare @counts int, @jobname nvarchar(1000), @cmd nvarchar(max)
set @counts = (select count(*) from #jobslist)
while @counts>=1
begin
set @jobname = (select name from #jobslist where rnk=@counts)
set @cmd = 'use msdb EXEC dbo.sp_stop_job N'+''''+@jobname+''''
--select @jobname
print @cmd
exec @cmd
set @counts=@counts-1
end
and getting this error
use msdb EXEC dbo.sp_stop_job N'JOBA' Msg 2812, Level 16, State 62, Line 30
Could not find stored procedure 'use msdb EXEC dbo.sp_stop_job N'JobA''.
1条答案
按热度按时间d4so4syb1#
Could you try this?