Stored procedure into a table?

  • Hello,

    If you have a stored procedure like:

    create proc testProc

    as

    select * from myTable

    Is there a way of executing that via a select statement rather than just exec?

    e.g. The following doesn't work, but shows the idea of what I'm after:

    select * from (exec testProc) where id = 1

    i.e. Selecting from the result set of the stored procedure without altering the procedure itself and without using parameters

    Thanks for any help, can't find it anywhere.

  • UDFs (user defined functions) could be used instead of sps. Alternatively (and less preferably) OpenDataSource or OpenRowSet would work.

    Paul Ibison

    Paul.Ibison@btinternet.com


    Paul Ibison
    Paul.Ibison@replicationanswers.com

  • Or you could just put the result into a temp table before the query.


    Cursors never.
    DTS - only when needed and never to control.

  • I'd recommend UDFs in SQL 2000 and a temp table in earlier versions.

    Steve Jones

    steve@dkranch.net

  • One of the limitations of Functions is that they cannot store data in permanent tables.

    Is this the case also with OPENDATASOURCE and OPENROWSET?

    My pre-lim enquiries suggest that this you cannot do this.

    Many thanks for comments / suggestions

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

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