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

Discussion
No comments for “Cursor In Stored Procedure”