Defines a cursor, by associating a select statement with a cursor name. You can use declare cursor with an archive database.
declare cursor_name [semi_sensitive | insensitive] [scroll | no scroll] [release_locks_on_close] cursor for select_statement [for {read only | update [of column_name_list]}]
declare authors_crsr cursor for select au_id, au_lname, au_fname from authors where state != 'CA'
declare titles_crsr cursor for select title, title_id from titles where title_id like "BU%" for read only
declare pubs_crsr cursor for select pub_name, city, state from publishers for update of city, state
declare stores_scrollcrsr insensitive scroll cursor for select stor_id, stor_name from stores where state = 'CA'
declare stores_scrollcrsr insensitive no scroll cursor for select stor_id, stor_name from stores where state = 'CA'
A declare cursor statement must precede any open statement for that cursor.
You cannot include other statements with declare cursor in the same Transact-SQL batch.
You can include up to 1024 columns in an update clause of a client’s declare cursor statement.
cursor_name must be a valid SAP ASE identifier containing no more than 30 characters.
You cannot include encrypted columns in the for update clause of a declare cursor statement.
You cannot update a scrollable cursor.
You cannot update an insensitive cursor.
ANSI SQL – Compliance level: Entry-level compliant.
No permission is required to use declare cursor.