Cursor Functions In SQL Server
What is Cursor function in SQL Server and why is it used ?
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
Sandeep Singh ShekhawatRank #147 · 15.6K reputationPosted Nov 1, 2012, 8:33 PM EDT
http://www.dotnet-tricks.com/Tutorial/sqlserver?id=4L7I050512&title=SQL%20Server%20-%20Basic%20of%20Cursor
http://www.dotnet-tricks.com/Tutorial/sqlserver/RLID060512-SQL-Server-Different-Types-of-Cursors.html
Satyapriya NayakRank #47 · 31.5K reputationPosted Nov 1, 2012, 11:01 PM EDT
Deepak MiddhaRank #214 · 11.3K reputationPosted Nov 3, 2012, 3:10 AM EDT
Fore more help visit http://www.c-sharpcorner.com/UploadFile/63f5c2/cursor-in-sql-server/
Rajeev KumarRank #1,334 · 1.3K reputationPosted Jul 10, 2023, 3:54 AM EDT
A cursor in SQL Server is a database object that allows us to retrieve each row at a time and manipulate its data. A cursor is nothing more than a pointer to a row. It's always used in conjunction with a SELECT statement.
Vishal YelveRank #178 · 13.6K reputationPosted Jul 10, 2023, 5:37 AM EDT
Hi Surrbhi,
Cursor is a database object to retrieve data from a result set one row at a time, instead of the T-SQL commands that operate on all the rows in the result set at one time. We use a cursor when we need to update records in a database table in singleton fashion means row by row.
Syntax
DECLARE cursor_name CURSOR [LOCAL | GLOBAL] --define cursor scope [FORWARD_ONLY | SCROLL] --define cursor movements (forward/backward) [STATIC | KEYSET | DYNAMIC | FAST_FORWARD] --basic type of cursor [READ_ONLY | SCROLL_LOCKS | OPTIMISTIC] --define locks FOR select_statement --define SQL Select statement FOR UPDATE [col1,col2,...coln] --define columns that need to be updatedDo refer below link
https://www.c-sharpcorner.com/UploadFile/f0b2ed/cursors-in-sql/
https://learn.microsoft.com/en-us/sql/t-sql/language-elements/declare-cursor-transact-sql?view=sql-server-ver16
https://www.dotnettricks.com/learn/sqlserver/sql-server-basics-of-cursors
https://www.mssqltips.com/sqlservertip/1599/cursor-in-sql-server/