Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Incremental load example 2 52
Impove long SQL Stored Procedure Performance 14 75
My Query is not giving correct result. Please help 5 40
kill process lock Sql server 9 51
Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
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 …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 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