DECLARE CURSOR
defines a cursor over a query; options set scrolling, sensitivity, updatability
What changes
- Input
- the cursor SELECT's sources (evaluated at OPEN)
- Output or change
- cursor definition
Syntax at a glance
DECLARE cursor_name [ INSENSITIVE ] [ SCROLL ] CURSOR FOR select_statement [ FOR { READ_ONLY | UPDATE [ OF column_name [ , ...n ] ] } ] [ ; ]
Work example
A task needs row-by-row work only after a set-based form has been ruled out.
Choose a local, read-only, forward-only cursor when it fits. Record the cleanup path before declaring it.
Check your work DECLARE CURSOR. The cursor scope and fetch direction match the work. A set-based alternative was considered first.
Open Microsoft Learn for full syntax, permissions, and details for your version.