Solved

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

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
OPENDATASOURCE 8 36
Upgrading SQL 2005 Express to 2008 R2 Express 31 68
Caste datetime 2 52
Urgent help needed! Unable to to paste in query designer 29 38
If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 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

20 Experts available now in Live!

Get 1:1 Help Now