Home All Groups Group Topic Archive Search About

SELECT INTO From Result Set

Author
14 Jul 2006 6:34 PM
Jim
Hi,

        We are using SQL Server 2005.

        Is it possible to fill a temporary table with the result set
from a stored procedure?  I want to do something like this:

SELECT *
INTO #Bicycles
FROM EXEC(Procedure Name)


Jim

Author
14 Jul 2006 6:40 PM
Tracy McKibben
Jim wrote:
Show quote
> Hi,
>
>         We are using SQL Server 2005.
>
>         Is it possible to fill a temporary table with the result set
> from a stored procedure?  I want to do something like this:
>
> SELECT *
> INTO #Bicycles
> FROM EXEC(Procedure Name)
>
>
> Jim
>

No, you have to create the table first, then

INSERT INTO #table
EXEC ProcedureName



--
Tracy McKibben
MCDBA
http://www.realsqlguy.com
Author
14 Jul 2006 6:40 PM
Aaron Bertrand [SQL Server MVP]
Create the temporary table first.

CREATE TABLE #Bicycles
(
    col1, col2, etc
)

INSERT #Bicycles EXEC ProcedureName;



Show quote
"Jim" <Jim.Muek***@wellsfargo.com> wrote in message
news:1152902093.325403.124060@i42g2000cwa.googlegroups.com...
> Hi,
>
>        We are using SQL Server 2005.
>
>        Is it possible to fill a temporary table with the result set
> from a stored procedure?  I want to do something like this:
>
> SELECT *
> INTO #Bicycles
> FROM EXEC(Procedure Name)
>
>
> Jim
>

AddThis Social Bookmark Button