omkar patade
omkar patade

Reputation: 1591

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?

Upvotes: 1

Views: 7771

Answers (2)

omkar patade
omkar patade

Reputation: 1591

Tried

EXEC msdb.dbo.sp_stop_job N'job name'

And it worked!

Upvotes: 2

TT.
TT.

Reputation: 16146

My best guess is you need SMO (SQL Server Management Objects) to pull this off. In particular take a look at the Job Class.

Upvotes: 0

Related Questions