Select * from the result of store procedure

  • Is it possible to run code as below? I knew it is not working but how to code to Select * from the result of store procedure?

    insert into #new_table select * from (the result of sp_order)?

  • What you're looking for is:

    Insert Into #table EXEC sp_proc


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • You can also do something like this if OPENROWSET is enabled:

    select

    a.*

    into

    #new_table

    from

    openrowset('SQLOLEDB','SERVER=(local);Trusted_Connection=yes;',

    '

    SET FMTONLY OFF;

    EXEC SP_HELPDB @dbname =''master''

    ') a

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

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