How a procedure call procedure variable

  • I have a stored procedure and I like to call this from select script.

    This stored procedure returns a record with one column wichi is a recordset by select command inside.

    How to call a stored procedure like below:

    select ID, (exec sp_return_name_recordset 1000) as name

    from nameTable

    where nameTable.ID='1000'

    Stored procedure accepts ID and returns a records of name value.

    how to combine select and stored procedure record in one record?

  • Errrr.... not sure just exactly what you're looking for so I offer this simple example on how to use a rowset from a stored procedure....

    USE PUBS

    GO

    SELECT a.*

    FROM OPENROWSET('MSDASQL',

                    'DRIVER={SQL Server};SERVER=seattle1;UID=sa;PWD=MyPass',

                    'EXEC SP_COLUMNS AUTHORS') AS a

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Use a Function:

    select ID, dbo.fn_return_name_recordset(ID) as name

    from nameTable

    where nameTable.ID='1000'

    /rockmoose


    You must unlearn what You have learnt

  • if you are using vb or asp..then use a executecommand on the stored procedure. This will return a recordset

    Hope that helps.

     

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

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