omkar patade omkar patade - 8 months ago 31
SQL Question

SQL Query - To stop/kill long running SQL job

I have a sql job who does some calculation in every 15 minutes.

Now i want to monitor this job. To check if that job is currently running and if yes then its been running for more than 10 minutes.

If it's running for more than 10 minutes then i want to stop/kill this job.

Is there any query available to do it?



EXEC msdb.dbo.sp_stop_job N'job name'

And it worked!