Home > DeveloperSection > Blogs > What is Cursor in SQL Server?

What is Cursor in SQL Server?


Database Database 
Ratings:
0 Comment(s)
 3525  View(s)
Rate this:


What is Cursor in SQL Server?


InSQL procedures, a cursor make it possible to define a result set (a set of datarows) and performs complex logic on a row by row basis. By using the samemechanics, an SQL procedure can also define a result set and return it directlyto the caller of the SQL procedure or to a client application.

Acursor can be viewed as a pointer to one row in a set of rows. The cursor canonly reference one row at a time, but can move to other rows of the result setas needed.

Touse cursors in SQL procedures, you need to do the following:


  • Declarea cursor that defines a result set.
  • Open the cursor to establish the result set.
  • Fetch the data into local variables as needed from the cursor, one row at atime.
  • Close the cursor when done.
Please check this link for detailed information

https://www.mindstick.com/Articles/428/implementing-concept-of-cursor-in-sql-server 


Don't want to miss updates? Please click the below button!

Follow MindStick