Results 1 to 2 of 2

Thread: Job Status

  1. #1
    Join Date
    Mar 2003
    Location
    Rio de Janeiro - Brazil
    Posts
    22

    Unanswered: Job Status

    Hey guys,

    I need to know the current status for a job that i started.

    I knew that sp_help_job give me all this information, but i have to do IF´s, so I have to set a variable with this result. I only need the columns last_run_outcome and current_execution_status.

    How do I to get only this values from a Job_id ??

    i Looked in almost all table from msdb to find these 2 columns and nothing ... :/


    Anyone can helpme ?

  2. #2
    Join Date
    Mar 2003
    Location
    Rio de Janeiro - Brazil
    Posts
    22
    The Answer Is :

    use master
    exec sp_addlinkedserver @server = 'LocalServer',
    @srvproduct = '',
    @provider = 'SQLOLEDB',
    @datasrc = @@servername
    go

    select last_run_outcome, current_execution_status from openquery(LocalServer, 'set fmtonly off; exec msdb.dbo.sp_help_job')
    go
    exec sp_dropserver 'LocalServer'

    U donot need to drop the linked server, I did that to ensure that noerror will be shoed when adding linked servers

    Bye

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •