I have a dynamic SQL statement I\'ve created in a stored procedure. I need to iterate over the results using a cursor. I\'m having a hard time figuring out the right syntax.
After recently switching from Oracle to SQL Server (employer preference), I notice cursor support in SQL Server is lagging. Cursors are not always evil, sometimes required, sometimes much faster, and sometimes cleaner than trying to tune a complex query by re-arranging or adding optimization hints. The "cursors are evil" opinion is much more prominent in the SQL Server community.
So I guess this answer is to switch to Oracle or give MS a clue.
for loop implicitly defines/opens/closes the cursor!)