HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Stop agent job after executing for a certain number of hours

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
afterexecutingnumberhoursagentstopforcertainjob

Problem

I have a scheduled job which runs nightly. I want it to stop itself at 07:00AM in the morning whether or not it is completed.

I have seen some duplicates in the site but they don't exactly address the problem.
Thanks.

Solution

Personally I would create another job and schedule it to run each morning at 7am.

A job step within that job could execute something like

USE msdb ;
GO

EXEC dbo.sp_stop_job
    N'' ;

Code Snippets

USE msdb ;
GO

EXEC dbo.sp_stop_job
    N'<Your job name>' ;

Context

StackExchange Database Administrators Q#85891, answer score: 8

Revisions (0)

No revisions yet.