How to invoke a job

  • Hi all,

    I need some help. I need to invoke a job based on some event. The job needs to be invoked from a stored procedure.

    Any ideas?

    Anything would help.

    Thanks

  • Use the sp_start_job system stored procedure for it. Look for help on it to find the details and other procedures that deal with jobs.

    Michael

  • Try something like:

    EXEC msdb..sp_start_job @job_name = @JobName

    Gary Johnson

    DBA

    Sr. DB Engineer




    Gary Johnson
    Microsoft Natural Language Group
    DBA, Sr. DB Engineer

    This posting is provided "AS IS" with no warranties, and confers no rights. The opinions expressed in this post are my own and may not reflect that of my employer.

  • The only downside with sp_start_job is if it is already running it will throw an error. Check the job state first before executing by using sp_help_job or look at it's code details and get out the select for just the execution status. Check it first and you can avoid the error.

  • Thanks a lot guys

    I really appreciate your help.

Viewing 5 posts - 1 through 4 (of 4 total)

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