Home >> FAQs/Tutorials >> SQL Server FAQ

SQL Server FAQ - What Are Cursors

By: FYIcenter.com

(Continued from previous topic...)

What Are Cursors?

A cursor is a special data type that represents a result set returned by a SELECT query statement. There are several notes about cursor you need to remember:

  • Cursor data type can not be used to define table columns.
  • Cursor data type is used on store procedures, functions, and triggers to help you loop through result sets returned by queries.
  • Cursor data type can be used to define cursor variables.
  • There are special Transact-SQL statements dedicated to work with cursors variables: OPEN, FETCH, CLOSE, and DEALLOCATE.
  • Cursor variables can be passed as procedure or function parameters.
  • There is a special function, CURSOR_STATUS(), for check cursor statuses.

(Continued on next topic...)

  1. What Are Cursors?
  2. How To Declare a Cursor with "DECLARE ... CURSOR"?
  3. How To Execute the Cursor Queries with "OPEN" Statements?
  4. How To Fetch the Next Row from a Cursor with a "FETCH" Statement?
  5. How To Transfer Data from a Cursor to Variables with a "FETCH" Statement?
  6. How To Loop through the Result Set with @@FETCH_STATUS?
  7. How To Declare and Use Cursor Variables?
  8. How To Create a Scrollable Cursor with the SCROLL Option?
  9. How To Create a Dynamic Cursor with the DYNAMIC Option?

Related Articles:


Other Tutorials/FAQs:


Related Resources:


Selected Jobs: