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 2005 Forums
 Transact-SQL (2005)
 Declare Cursor from Stored Proc Resultset

Author  Topic 

dmagoo22
Starting Member

2 Posts

Posted - 2009-07-31 : 13:24:58
I'm trying to populate a temp table from the results of a stored proc (which is a select statement).

First off, I do not have access to the stored proc to modify it. I can only run the proc. The only way I can think of is by creating a cursor from the stored procs resultset. However, when I declare the cursor it doesn't like my "execute" statement when calling the stored proc.

Does anyone know of another way to loop through the result set other than a cursor? Or how can I declare a cursor from the stored proc?

Thanks in advance,

Dennis

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-07-31 : 14:13:21
forget the cursor idea - just insert directly:

insert <yourTargetTAble>
exec <yourSP>

you just need to make sure your target table matches the structure of the SP output.

Be One with the Optimizer
TG
Go to Top of Page

dmagoo22
Starting Member

2 Posts

Posted - 2009-07-31 : 15:43:18
Thanks!
Go to Top of Page
   

- Advertisement -