Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2008-10-23
3
201 Views
Last Modified: 2012-05-05
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
Comment
Question by:PMH4514
  • 2
3 Comments
 
LVL 39

Expert Comment

by:BrandonGalderisi
ID: 22790564
Yeah.... you can't do that.
0
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 50 total points
ID: 22790572
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
 

Author Comment

by:PMH4514
ID: 22790769
thanks Brandon!
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question