How to use a SP within Select Statement of another SP

  • Hi,

    I have a SP whose ouput i need to use in another SP.

    I wish to use the output of this SP in another SP.

    However,I am aware of using a table variable to store the results of the first one and then using it.

    Is there any other solution apart from this.

    Can i directly call the SP from select stmt [ specifically in from clause of select stmt] ?

    Any help on this would be appreciated.

    Thanks and Regards,

    Priyanka

  • You could create a temporary table and then INSERT the output of the EXEC into it:

    Create table #temp(

    ...

    )

    INSERT into #temp

    EXEC spFubar

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • priyanka.scholar (12/14/2008)


    Hi,

    I have a SP whose ouput i need to use in another SP.

    I wish to use the output of this SP in another SP.

    However,I am aware of using a table variable to store the results of the first one and then using it.

    Is there any other solution apart from this.

    Can i directly call the SP from select stmt [ specifically in from clause of select stmt] ?

    Any help on this would be appreciated.

    Thanks and Regards,

    Priyanka

    you cannot use sp in the select statusement, ut you can use Functions instead of that

    kshitij kumar
    kshitij@krayknot.com
    www.krayknot.com

  • Hi RBarryYoung,

    Thanks for replying. However I am aware of this solution.

    Is there any other soln without the use of temp tables?

    I mean, can I use the SP and pass the parameters and directly use the Output columns to join with another table.

    Thanks,

    Priyanka

  • You cannot use output columns of a sp to join with other tables.

    "Keep Trying"

  • Thanks a lot for all the replies.

  • priyanka.scholar (12/14/2008)


    Is there any other soln without the use of temp tables?

    I mean, can I use the SP and pass the parameters and directly use the Output columns to join with another table.

    No.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • The only RDBMS system that I know of that allows using stored procedures like tables is InterBase.

    It happened to be one of the RDBMS we were evaluating at my previous employer back in 1996.

Viewing 8 posts - 1 through 7 (of 7 total)

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