SP returning a table -- ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim Geissman

    SP returning a table -- ?

    There's an SP that in effect returns a table -- it loops and executes
    statements like SELECT @field1, @Field2, @Field2

    Can I capture its results in a table? I know that if it were a FUNCTION
    that returned a table, that would be simple:

    INSERT ResultsTable SELECT * FROM dbo.Function (@Param1, @Param2)

    But how to do that if the code is a procedure rather than a function?
  • John Bell

    #2
    Re: SP returning a table -- ?

    Hi

    Check out the form of insert statement that calls exec

    INSERT INTO <TABLE> execute_stateme nt

    i.e INSERT INTO <TABLE> EXEC stored_procedur e



    John


    "Jim Geissman" <jim_geissman@c ountrywide.com> wrote in message
    news:b84bf9dc.0 308291355.6af69 0b6@posting.goo gle.com...[color=blue]
    > There's an SP that in effect returns a table -- it loops and executes
    > statements like SELECT @field1, @Field2, @Field2
    >
    > Can I capture its results in a table? I know that if it were a FUNCTION
    > that returned a table, that would be simple:
    >
    > INSERT ResultsTable SELECT * FROM dbo.Function (@Param1, @Param2)
    >
    > But how to do that if the code is a procedure rather than a function?[/color]


    Comment

    Working...