SQL Server Agent - Job History - Output Log

  • Hello Guys and Girls,

    As we all know, SQL Agent will not be shipped with SQL Express and the versions following. I am creating a stand alone application that will replicate SQL Agent - and my problem lies in the fact that I would like to have a Job History page, just like the one in SQL Agent; The first step would be to have the output piped to a text file, but I do not know how the output is created. I am guessing it should be a stored procedure. If anyone could give advise on this one, I would greatly appreciate it...:-D

  • In the msdb database check the following stored procedure:

    sp_sqlagent_log_jobhistory - I believe it is what you are looking for. It is a long proc so read it all.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • to get the hex value of your job:

    select job_id from msdb.dbo.sysjobs where name = 'your_job_name'

    to run the sp mentioned above use the following format:

    EXECUTE msdb.dbo.sp_sqlagent_log_jobhistory

    @job_id = '374DECBA-F44D-48BB-97A9-DDBBBC100F13', -- this is the value returned by the query above

    @step_id = 0,

    @sql_message_id = 0,

    @sql_severity = 0,

    @run_status = 1,

    @run_date = 20090429,

    @run_time = '165100',

    @run_duration = 1,

    @operator_id_emailed = 0,

    @operator_id_netsent = 0,

    @operator_id_paged = 0,

    @retries_attempted = 0,

    @message = N'The job succeeded'

    this does however not return a listing with history information, it just says: "Command(s) completed successfully."

    :hehe: Am I missing something?

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply