Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Is it possible to put the returned record set of a stored procedure into a cursor.
I have dynamically created a sql statement which is being executed by the EXEC sp_executeSQL, but I wish to put the results into a cursor so that I can scroll through them.
It is possible to insert the results into a temporary table, but being able to put them in a cursor would save me some work.
Posted
Updated 13-Jul-11 7:45am
v2
Comments
Emrah Taylan 13-Jul-11 11:13am    
I think You must prefer sql function

1 solution

Create a temp table (CREATE TABLE #cursname...) or cursor (DECLARE @cursname CURSOR for...)

Then use something like
INSERT INTO #cursname 
EXEC sp_executeSQL


[edit]
Just realized I mixed temp table and cursor.
[/edit]
 
Share this answer
 
v2
Comments
Abhinav S 13-Jul-11 13:45pm    
Good answer. My 5.
RaviRanjanKr 13-Jul-11 16:40pm    
Nice Answer, My 5+

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900