SQL

Cursor In Stored Procedure



Cursor in sql is used to implement looping structure.Its just like using for loop or while loop in cpp.

 

Sample Code

 

Declare @variablename varchar(255)

DECLARE CursurName  CURSOR FOR SELECT columnname FROM tablename

OPEN CurserName  FETCH NEXT FROM CurserName  INTO @variablename

WHILE @@FETCH_STATUS = 0

BEGIN

 

//implement the logic here

END

FETCH NEXT FROM Answers_Cursor INTO @variablename

END

Share

Thanks for reading my blog. If you like what I write, why not subscribe to my feed?

If you are busy, I can send the latest post to your email. Just subscribe to my email updates.

 

Enter your email address:

Delivered by FeedBurner

Discussion

No comments for “Cursor In Stored Procedure”

Post a comment