Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Stored Procedure Results To Table

Author  Topic 

s_narayanan
Starting Member

3 Posts

Posted - 2004-04-06 : 12:04:04
Hi All,

Is there a way in SQL Server to get the results out of a stored procedure into a table or cursor?

Thanks in advance

Narayanan Sankaranarayanan

The Enigma
Posting Yak Master

179 Posts

Posted - 2004-04-06 : 12:43:09
insert into table(col_1, col_2, ...,col_n) exec storedproc
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-04-06 : 12:51:40
Please do not post your question in more than one forum:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=33999

Tara
Go to Top of Page

GunterKDR
Starting Member

5 Posts

Posted - 2004-04-06 : 13:09:41
Yes.

Declare a table, then insert into with an EXEC.

Something like:

CREATE TABLE #myTable (
a int ,
b int )

INSERT INTO #myTable
EXEC MyProc


Just make sure your column counts are the same, or specify the columns explicitly, as in:

INSERT INTO #myTable ( a, b )
EXEC MyProc




quote:
Originally posted by s_narayanan

Hi All,

Is there a way in SQL Server to get the results out of a stored procedure into a table or cursor?

Thanks in advance

Narayanan Sankaranarayanan




They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety. -- Benjamin Franklin
Go to Top of Page
   

- Advertisement -