What are cursors in SQL Server?
- Cursors allow row-by-row processing of the resultsets.
- It is a database object which is used to retrieve data from a resultset one row at a time.
Following are the types of cursors: 1. Static
2. Dynamic
3. Forward-only
4. Keyset-driven.
- Each time you fetch a row from the cursor, it results in a network roundtrip.
- Cursors are also costly because they require more resources and temporary storage.
Syntax:DECLARE CURSOR CURSOR_NAME
Example:DECLARE CURSOR empId_cur