The topic describes the DF023 T-SQL code analysis rule.
BEST PRACTICE
The cursor is not closed and/or deallocated.
The cursor is opened but not closed and/or deallocated. Locally opened cursors should be explicitly closed to preserve resources.
Leaving cursors open can lead to resource contention and memory leaks, as the database engine continues to hold onto resources associated with the cursor until it is explicitly closed and deallocated.
DECLARE cur CURSOR LOCAL FOR
SELECT CustomerID FROM dbo.Customer
OPEN cur
FETCH NEXT FROM cur INTO @CustomerId
DECLARE cur CURSOR LOCAL FORWARD_ONLY FOR
SELECT CustomerID FROM dbo.Customer
OPEN cur
FETCH NEXT FROM cur INTO @CustomerId
DEALLOCATE cur