Help Putting Stored Procedure In a Stored Procedure/View

  • I am trying to gather job information from sp_help_job, but can't figure out how to get the information from this sp into either another sp/view or table.

    Tim

  • create a #tmptb according to the output you expect (check BOL !!)

    then just perform

    insert into #tmptb

    exec sp_help_job

    "et voila" you have the results in the temp table.

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • When I do that I receive the error::crying:

    "Msg 8164, Level 16, State 1, Procedure sp_get_composite_job_info, Line 72

    An INSERT EXEC statement cannot be nested."

    There are 'INSERT' statements in various other procedures called by sp_help_job.

    Is there anything else I can try?

    Tim

  • keep in mind the output may varry according to your input parameters (check bol)

    Can you post your exact statement ?

    Indeed it gives an error, but the temptb is being filled up ...

    create table #tmptb (

    job_id uniqueidentifier ,

    originating_server nvarchar(30) ,

    name sysname ,

    enabled tinyint ,

    description nvarchar(512) ,

    start_step_id int ,

    category sysname ,

    owner sysname ,

    notify_level_eventlog int ,

    notify_level_email int ,

    notify_level_netsend int ,

    notify_level_page int ,

    notify_email_operator sysname ,

    notify_netsend_operator sysname ,

    notify_page_operator sysname ,

    delete_level int ,

    date_created datetime ,

    date_modified datetime ,

    version_number int ,

    last_run_date int ,

    last_run_time int ,

    last_run_outcome int ,

    next_run_date int ,

    next_run_time int ,

    next_run_schedule_id int ,

    current_execution_status int ,

    current_execution_step sysname ,

    current_retry_attempt int ,

    has_step int ,

    has_schedule int ,

    has_target int ,

    type int )

    insert into #tmptb

    exec sp_help_job

    select *

    from #tmptb

    -- cleanup

    drop table #tmptb

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • Tim Riley (4/2/2008)


    When I do that I receive the error::crying:

    "Msg 8164, Level 16, State 1, Procedure sp_get_composite_job_info, Line 72

    An INSERT EXEC statement cannot be nested."

    There are 'INSERT' statements in various other procedures called by sp_help_job.

    Is there anything else I can try?

    Tim

    Use OPENROWSET?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

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

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