Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use a Stored Procedure in a cursor

Status
Not open for further replies.

mflancour

MIS
Joined
Apr 23, 2002
Messages
379
Location
US
DECLARE cur_recordwriter_id CURSOR FOR
(exec sp_DataSourceEnabled)
OPEN cur_recordwriter_id
FETCH NEXT FROM cur_recordwriter_id INTO @v_datasource_id, @v_url_site, @v_clientkey_id, @v_domain, @v_url_privacypolicy


I have a stored proc that is ecentially a query. I need to call this proc and use a cursor to go through each record. How?
 
What exactly are you trying to do, most times what you want done can be done with a set based operation. If you must loop throug the data, then use a while loop instead of a cursor.
 
Capture the results of the stored procedure in to a temp table and then cursor through the temp table.

Ex:

[tt][blue]
Create Table #Temp(field1 datatype1, field2 datatype2, etc..)

Insert Into #Temp
Exec sp_DataSourceEnabled

-- Now cursor through the temp table.
[/blue][/tt]

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top