Solved

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

Posted on 2008-10-23
3
198 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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now