Using Stored Procedure to populate Temporary Table

  • Hi,

    I would like to use one of the already existing Stored procedure logic to populate current procedure's temporary table just to make use of the existing logic.

    Problem here is that, the existing SP returns two result sets as below.

    Result Set 1: Count of the records

    Result Set 2: Actual record set rows that matches the count returned in the result set 1.

    How ever, I would like to capture only the first result set (Count of the records) into the temp table of currently developing SP. Based on my testing, I found that we can not use an SP returning more than one result set to populate temp table(INSERT-EXECUTE).

    Is there any solution to achieve this?

    Thanks in advance,

    Suresh

    Regards,
    Suresh Arumugam

  • Hi Suresh,

    Can you please check the tutorial named How to SQL Select from Stored Procedure using SQL Server OPENQUERY or OPENROWSET

    When I use a code like below

    SELECT *

    into #t

    FROM OPENQUERY([.], 'MySQLSamples.dbo.GetDBObjects') query

    where the GetDBObjects proc returns more than one result sets, only the first result set is used for populating temp table.

    Perhaps you can use this structure.

    I hope that helps,

    Eralper

  • Thanks a lot EralPer! I will try them out.

    Regards,
    Suresh Arumugam

Viewing 3 posts - 1 through 2 (of 2 total)

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