Store proceure with multiple result sets

  • Dear All

    I have one procedure PROC1 wich resturn multiple result sets. No of coulmn and Datatype of the result set are not same.

    I want to access the result of PROC1 from another proceure PROC2. How do i do it?

    Regards

    Krishna

  • Krishna1 (4/30/2013)


    Dear All

    I have one procedure PROC1 wich resturn multiple result sets. No of coulmn and Datatype of the result set are not same.

    I want to access the result of PROC1 from another proceure PROC2. How do i do it?

    Regards

    Krishna

    You'd probably need to use INSERT...EXEC within PROC2 to do this.

    I believe you can also do it with OPENROWSET but I wouldn't really advise that approach.

    Are you trying to access the resultsets as one set?

  • Hi

    I am uisng following code. How do create a table for insert into when 2 resul sets are differnt? Please advice.

    CREATE procedure PROC1 as

    begin

    Select 'aaa',1

    select 1,2.22,'xxx'

    end

    go

    DROP PROCEDURE PROC2

    go

    Create procedure PROC2 as

    BEGIN

    INSERT INTO #temp

    EXECUTE PROC1

    SELECT * FROM #temp

    END

    go

    execute PROC2

    Regards

    Krishna

  • Krishna1 (4/30/2013)


    Hi

    I am uisng following code. How do create a table for insert into when 2 resul sets are differnt? Please advice.

    CREATE procedure PROC1 as

    begin

    Select 'aaa',1

    select 1,2.22,'xxx'

    end

    go

    DROP PROCEDURE PROC2

    go

    Create procedure PROC2 as

    BEGIN

    INSERT INTO #temp

    EXECUTE PROC1

    SELECT * FROM #temp

    END

    go

    execute PROC2

    Regards

    Krishna

    I think you might find that INSERT...EXEC will let you down in that instance. I don't believe you can capture multiple resultsets with it.

    In fact, as I think about it, the only way that comes to my mind to handle that kind of thing anywhere near gracefully would be with the CLR.

    I'm assuming you don't have the option of altering the Procedure itself?

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

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