Use of Cursor in Stored Procedure

Wednesday, October 7, 2009

Using below code you can learn, how to use cursor in Stored Procedure

DECLARE @dListingEnddate datetime

DECLARE cur_enddate1 CURSOR FOR( select top 10 dListingEnddate as dListingEnddate from jau_productmaster)

/* Open Corsor */
OPEN cur_enddate1

FETCH NEXT From cur_enddate1 INTO @dListingEnddate

WHILE @@Fetch_Status = 0

/*Put your sql query here*/
--INSERT INTO GK_ShareEvent (iShareEventID,iEventAudienceID)

FETCH NEXT From cur_enddate1 INTO @dListingEnddate


/* Close Corsor */
CLOSE cur_enddate1

DEALLOCATE cur_enddate1


Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)

No comments :