August 6, 2008 at 1:51 pm
does anyone know of a way to tell who started a SQL agent job?
August 6, 2008 at 2:31 pm
Error log?
I think a Trace on sp_start_job might be the best way to pro-actively get this.
August 6, 2008 at 2:40 pm
yeah, that should work. I was hoping to get one in the past, but it may not be possible.
August 6, 2008 at 3:35 pm
The job history will have a login name that started the job within the message column
SELECT *
FROM [msdb].[dbo].[sysjobhistory]
where message like '%The Job was invoked by User%'
SQL = Scarcely Qualifies as a Language
August 6, 2008 at 3:45 pm
The easiest way is to look at the job history in Management Studio, it's the last line of the "selected row details:" section. Or you can see it by query:
[font="Courier New"]SELECT j.name AS job_name, jh.step_name, jh.sql_message_id, jh.sql_severity, jh.message,
cast((jh.run_date / 100) % 100 AS VARCHAR(2)) + '/' + cast(jh.run_date % 100 AS VARCHAR(4)) + '/' + cast(jh.run_date / 10000 AS VARCHAR(4)) AS date,
cast(jh.run_time / 10000 AS VARCHAR(2)) + ':' + RIGHT('00' + cast((jh.run_time / 100) % 100 AS VARCHAR(2)), 2) AS time,
cast((jh.run_duration / 10000) % 100 AS VARCHAR(2)) + ':' + RIGHT('00' + cast((jh.run_duration / 100) % 100 AS VARCHAR(2)), 2) + ':' + RIGHT('00' + cast(jh.run_duration % 100 AS VARCHAR(2)), 2) AS duration
FROM msdb.dbo.sysjobhistory AS jh
INNER JOIN msdb.dbo.sysjobs AS j ON j.job_id = jh.job_id
WHERE jh.run_date >= CONVERT(int, CONVERT(varchar(8),GETDATE()-1,112))
--AND jh.run_status = 1
AND jh.step_id = 0
ORDER BY jh.run_date DESC, jh.run_time DESC[/font]
the message column will say something like either:
The job succeeded. The Job was invoked by Schedule ...
or:
The job succeeded. The Job was invoked by User ...
August 7, 2008 at 12:22 am
The easiest way is to find it through job history..
Message
The Job was invoked by "the person or the account"
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply