Why do people hate SQL cursors so much?

Posted by Steven A. Lowe on Stack Overflow See other posts from Stack Overflow or by Steven A. Lowe
Published on 2008-11-13T16:39:14Z Indexed on 2010/04/07 21:23 UTC
Read the original article Hit count: 400

Filed under:
|

I can understand wanting to avoid having to use a cursor due to the overhead and inconvenience, but it looks like there's some serious cursor-phobia-mania going on where people are going to great lengths to avoid having to use one

for example, one question asked how to do something obviously trivial with a cursor and the accepted answer proposed using a common table expression (CTE) recursive query with a recursive custom function, even though this limits the number of rows that could be processed to 32 (due to recursive call limit in sql server). This strikes me as a terrible solution for system longevity, not to mention a tremendous effort just to avoid using a simple cursor.

what is the reason for this level of insane hatred? has some 'noted authority' issued a fatwa against cursors? does some unspeakable evil lurk in the heart of cursors that corrupts the morals of the children or something?

wiki question, more interested in the answer than the rep

thanks in advance!

Related Info:

http://stackoverflow.com/questions/37029/sql-server-fast-forward-cursors

EDIT: let me be more precise: I understand that cursors should not be used instead of normal relational operations, that is a no-brainer. What I don't understand is people going waaaaay out of their way to avoid cursors like they have cooties or something, even when a cursor is a simpler and/or more efficient solution. It's the irrational hatred that baffles me, not the obvious technical efficiencies.

© Stack Overflow or respective owner

Related posts about sql

Related posts about cursor