question

eghetto avatar image
eghetto asked

Who stopped (canceled) my SQL Server Agent Job?

Dear All, in my job (step) history a can see the following statement: ***"Executed as user: XX\\yyyy. The step was cancelled (stopped) as the result of a stop job request."*** Is there a way to find out who stopped this job? Thanks!
sql-server-2008-r2sql-agentjobjob-history
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
tanglesoft avatar image
tanglesoft answered
If you view the job history from SSMS in the message it will say 'The job was stopped prior to completion by user xxx.'
8 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

The information is recorded in msdb..sysjobhistory also
0 Likes 0 ·
Thanks - piece of code?
0 Likes 0 ·
select message,* from msdb..sysjobhistory hope it may help to you by www.sqltechi.blogspot.in
0 Likes 0 ·
If you execute select
0 Likes 0 ·
sorry, but the message column just contains "Executed as user: XX\yyyy. The step was cancelled (stopped) as the result of a stop job request." There is no information about the user who canceled the job. Or am I missing something...?
0 Likes 0 ·
select top 1 message from msdb.dbo.sysjobs job join msdb.dbo.sysjobhistory history on job.job_id = history.job_id where name = 'YourJobName' order by run_date, run_time desc
0 Likes 0 ·
Got it now: No name but a reason --> "The job was stopped prior to completion by Shutdown Sequence 0." here is the code I've used: SELECT job.name ,history.message ,history.run_status FROM msdb.dbo.sysjobs job JOIN msdb.dbo.sysjobhistory history ON job.job_id = history.job_id WHERE history.run_status = 3 ORDER BY run_date ,run_time DESC
0 Likes 0 ·
I have modified the SQL below because you need the job outcome from step 0 not the step detail. select top 1 message, * from msdb.dbo.sysjobs job join msdb.dbo.sysjobhistory history on job.job_id = history.job_id where name = 'YourJob' and step_id = 0 order by run_date, run_time desc
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.