SQL Server › Cursors

What does the FAST_FORWARD cursor option do, and when should you use it?

Intermediate

Answer

The FAST_FORWARD option creates an optimized, read only, forward only cursor specifically designed for the best possible performance when you only need to read through data once without making any changes, making it a good default choice whenever a cursor truly is the necessary tool for a specific task.
DECLARE report_cursor CURSOR FAST_FORWARD FOR
SELECT OrderId, Amount FROM Orders WHERE Status = 'Completed';
Real-world example A reporting script that must call an external function once for each completed order uses a FAST_FORWARD cursor to minimize the performance overhead of the row by row processing that is unavoidable in this specific case.

Common follow-ups: How does FAST_FORWARD compare to a regular forward only cursor in terms of performance?;Can a FAST_FORWARD cursor be used to update data as it goes?