Populate temp table from values returned from a different SP?

  • I would really appreciate any direction on how to accomplish the following in a stored procedure.

    General idea:

    1) create a #tmpTable CREATE #tmpTbl1 ( [fld defs] ...

    2) insert into that new #tmpTbl1 a row of values returned by executing a separate stored procedure - like

    INSERT

    INTO

    #tmpTbl1 (val1, val2, val3, val4 )

    SELECT

    val1, val2, val3, val4

    FROM

    ( EXEC SP2 @param1=123 )

    3) insert another record into that new #tmpTbl1 by calling the same SP with different param(s):

    INSERT

    INTO

    #tmpTbl1 (val1, val2, val3, val4 )

    SELECT

    val1, val2, val3, val4

    FROM

    ( EXEC SP2 @param1=456 )

    Any and all guidance is appreciated!

  • This should do:

    --2) insert into that new #tmpTbl1 a row of values returned by executing a separate stored procedure

    INSERT #tmpTbl1 (val1, val2, val3, val4 )

    EXEC SP2 @param1=123

    --3) insert another record into that new #tmpTbl1 by calling the same SP with different param(s):

    INSERT #tmpTbl1 (val1, val2, val3, val4 )

    EXEC SP2 @param1=456

    -- Gianluca Sartori

  • It DID do!

    Of all the combinations I tried, failed to come up with that one.

    Sincerest thanks!

  • You're welcome.

    Glad I could help.

    -- Gianluca Sartori

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

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