Stats

183 Contributors: 2
2016-07-28
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook

Cursors

Download sql-server eBook

Syntax

  • DECLARE cursor_name CURSOR [ LOCAL | GLOBAL ]
    • [ FORWARD_ONLY | SCROLL ]
      [ STATIC | KEYSET | DYNAMIC | FAST_FORWARD ]
      [ READ_ONLY | SCROLL_LOCKS | OPTIMISTIC ]
      [ TYPE_WARNING ]
    • FOR select_statement
    • [ FOR UPDATE [ OF column_name [ ,...n ] ] ]

Remarks

Normally you would want to avoid using cursors as they can have negative impacts on performance. However in some special cases you may need to loop through your data record by record and perform some action.

Related Examples