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 procedure result set?

Author  Topic 

nwalter
Starting Member

39 Posts

Posted - 2009-01-22 : 16:49:46
How can I declare a cursor that uses the result set from another stored procedure?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-01-22 : 16:51:38
Put the result set into a temp table via the INSERT INTO/EXEC method and then use the temp table in the cursor.

CREATE TABLE #t1 (Column1 int, Column2 varchar(5))

INSERT INTO #t1 (Column1, Column2)
EXEC SomeProc...

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

nwalter
Starting Member

39 Posts

Posted - 2009-01-22 : 16:54:17
Was hoping it wouldn't be a temp table.. The cursor is bad enough to deal with. :(

Oh well thanks!
Go to Top of Page
   

- Advertisement -