Who started the job?

  • does anyone know of a way to tell who started a SQL agent job?

  • Error log?

    I think a Trace on sp_start_job might be the best way to pro-actively get this.

  • yeah, that should work. I was hoping to get one in the past, but it may not be possible.

  • 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

  • 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 ...

  • 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