views:

97

answers:

1

I would like to get the out put of a stored proc call and create a permanent table with out specifying columns. Because the stored proc return lots of columns...

So.. how can I do this??

SELECT * INTO MYTABLE FROM MYSTOREDPROC @PARAM1 = 1, @PARAM2 = 'HELLO'

is it possible??

Example would help me alot

+5  A: 

you can't generate the table from calling stored procedure. However, edit the called stored procedure and alter the select that generates the result set to have an INTO YourNewTable clause:

SELECT
   columns....
   INTO YourNewTable
   from ...
   where
   order by...

Run the procedure 1 time, to generate the table. remove the changes (INTO YourNewTable clause) and then call the procedure as:

INSERT INTO YourNewTable
    EXEC YourProcedure params...
KM