Hi,
I want to know that what is the role of cursor in database and how can i implement it?
Thanks
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Jan 24, 2012, 6:16 AM EST
http://www.c-sharpcorner.com/UploadFile/sairevoori/cursor-in-sql-server/
Satyapriya NayakRank #47 · 31.5K reputationPosted Jan 24, 2012, 7:31 AM EST
Please refer the below link
http://plsql-tutorial.com/plsql-cursors.htm
Thanks
Mukesh KumarRank #615 · 3.9K reputationPosted Jan 24, 2012, 8:02 AM EST
refer this link http://www.mssqltips.com/sqlservertip/1599/sql-server-cursor-example/
Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 24, 2012, 8:43 PM EST
A cursor is a set of rows together with a pointer that identifies a current row.
In other word, Cursor is a database object used by applications to manipulate data in a set on a row-by-row basis.
DECLARE @fName varchar(50), @lName varchar(50)
DECLARE cursorName CURSOR -- Declare cursor
LOCAL SCROLL STATIC
FOR
Select firstName, lastName FROM myTable
OPEN cursorName -- open the cursor
FETCH NEXT FROM cursorName
INTO @fName, @lName
PRINT @fName + ' ' + @lName -- print the name
WHILE @@FETCH_STATUS = 0
BEGIN
FETCH NEXT FROM cursorName
INTO @fName, @lName
PRINT @fName + ' ' + @lName -- print the name
END
CLOSE cursorName -- close the cursor
DEALLOCATE cursorName -- Deallocate the cursor
hope this help.