Return a Cursor from Store Procedure to Other Store Procedure

  • I am triying to Obtain the Cursor Data from a Store Procedure to other Store Procedure.

    How I can make this?

    Thanks

     

     

  • Don't...

    Why do you think you need to do this?

  • I'm not exactly sure what you mean cursor data.

    But you cannot easily pass Recordsets between stored procedures.

    You have to persist the data to a temporary table and you have to call the procedures in a certain order to preserve the table/data.

    Create a top level procedure, which creates a temp table, and then calls a nested procedure that populates the temp table.

    Then the calling table will have access to the temp table, and the data in it.

    Create Nestedprocedure as

    Insert into #TEMP

    Select data

    from Table

    Go

    create Proc1 as

    Create Table #TEMP(PK int identity, ....)

    exec Nestedprocedure

    Select data from #Temp

    GO

     

    I do not belieive you can declare a cursor, and then call a nested procedure to use the cursor.

    Please post tables, sample data and information about what your trying to do.

    You may be able to avoid nesting procedures, and cursors altogether

    Damit Remi, Your too fast

  • There's no such thing as too fast .

  • Yes the Temproally table are one option, but there not is other easy and less expensive tecnically talking.

     

  • I am trying to obtain and use data into a Store Procedure that other Store PRocedure Produces before.

    Thank you.

     

  • > I want stored procedure A to call stored procedure B, which returns a set of

    > records from a table. Then, I want stored procedure A to perform work on

    > these records. How do I call stored procedure B from within stored procedure

  • A bit of light reading.

    I do not believe there is an "Easier way"

    This article discusses several options

    Output Parameters

    Rewriting query using table valued functions

    Sharing TempTables

    Insert/Exec

    Openquery.

    http://www.sommarskog.se/share_data.html

  • As you say there is not an easy way to do that I gonna read.

     

    But tanks for your help

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

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