June 5, 2013 at 8:28 am
Hi Experts,
We have maintenance jobs running on all servers on weekends .Is there anyway i can stop these jobs if these jobs still run on monday morning.
Thanks in Advance
June 5, 2013 at 8:42 am
You can schedule a job that runs Monday morning at a certain time and runs the following:
You can use this query to get a list of the currently executing job names:
SELECT [sjv].[name]
FROM [msdb].[dbo].[sysjobs_view] sjv
JOIN [msdb].[dbo].[sysjobactivity] sja ON [sjv].[job_id] = [sja].[job_id]
WHERE [sja].[run_requested_date] IS NOT NULL
AND [sja].[stop_execution_date] IS NULL
--AND sjv.name LIKE '%YourMaintJobName(s)Here%'
Then pass the job names through sp_stop_job:
EXEC msdb.dbo.sp_stop_job @jobname
Twitter: @SQL_JGood
Blog: sqljgood.wordpress.com/[/url]
June 5, 2013 at 9:04 am
Thanks a lot J.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply