• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

Declare cursor for --- the output of a stored procedure?

I have a stored procedure proc_users_select that returns a set of results.

I could do something like this:

DECLARE MY_CURSOR CURSOR FOR
SELECT * FROM USERS

however, my stored procedure isn't quite that simple, so what I'd rather do is:

DECLARE MY_CURSOR CURSOR FOR
proc_users_select

but I get an error message
Incorrect syntax near 'proc_users_select'.

Is this not allowed or is my syntax just wrong?

thanks
0
PMH4514
Asked:
PMH4514
  • 2
1 Solution
 
BrandonGalderisiCommented:
Yeah.... you can't do that.
0
 
BrandonGalderisiCommented:
you could do


create table #T (...
 )
--where #t matches the output format of proc_users_select
insert into #t
exec proc_users_select
 
DECLARE MY_CURSOR CURSOR FOR
select * from #t

Open in new window

0
 
PMH4514Author Commented:
thanks Brandon!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now