SQL Server Cursor
Cursor is a variable in SQL Server Database which is used for row-by row operations. The cursor is so named because it indicates the current position in the resultset.
Life Cycle of Cursor
Declare Cursor
A cursor is declared by defining the SQL statement that returns a result set.Open
A Cursor is opened and populated by executing the SQL statement defined by the cursor.Fetch
When cursor is opened, rows can be fetched from the cursor one by one or in a block to do data manipulation.Close
After data manipulation, we should close the cursor explicitly.Deallocate
Finally, we need to delete the cursor definition and released all the system resources associated with the cursor.