EXEC Sp in another sp.

  • I have doubt Recording SP's i have to use previous developed sp in my present sp. here previous sp returns 4 tables but i want 2nd table only. Example code:

    IF object_id('SPForGetStaticCCValues',N'P') IS NOT NULL DROP PROCEDURE SPForGetStaticCCValues; GO CREATE PROCEDURE SPForGetStaticCCValues AS BEGIN

    EXEC spCCLocateCleaned '','','','',95

    End

    here spCCLocateCleaned SP returns 4 tables how to find 2nd table?

    Prasad.N
    Hyderabad-India.

  • I dont think there is way to do this upto 2008 versions. But 2012 provides a way to get the resultsets handy.

    Which version you are using?

  • You can use one more parameter for controlling the output from first proc. And set a default value and will get all four results by default.

  • Prasad.N (6/11/2012)


    I have doubt Recording SP's i have to use previous developed sp in my present sp. here previous sp returns 4 tables but i want 2nd table only. Example code:

    IF object_id('SPForGetStaticCCValues',N'P') IS NOT NULL

    DROP PROCEDURE SPForGetStaticCCValues;

    GO

    CREATE PROCEDURE SPForGetStaticCCValues

    AS

    BEGIN

    EXEC spCCLocateCleaned '','','','',95

    End

    here spCCLocateCleaned SP returns 4 tables how to find 2nd table?

    Unfortunately, looking at this code doesn't tell us anything. To help you we will need to see the code for spCCLocateCleaned.

    A shot in the dark tells me that this procedure returns 4 separate result sets, which means you would need to use MARS (Multiple Active Results Sets) to access each one. Not sure how you would do this in SQL, and I haven't purchased SQL Server 2012 Developer Edition yet, so can't tell you if you can do what you want there.

  • 2008 r2

    Prasad.N
    Hyderabad-India.

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

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