• Lynn Pettis (3/10/2008)


    Cursors may be evil, but they may be a necessary evil...

    In my experience they are necessary and acceptable for only one thing: variable-izing SQL objects in the repeated execution of dynamic SQL or system procedures. In other words: DBA operational utility procedures (and these are not normally written by the uninitiated, nor should they be). And even in this case, there are very often acceptable ways around it.

    Although I have heard many other allusions to possible instances where cursors were necessary, not one has materialized and I have begun to regard it as an urban legend.

    I would like to keep an open mind on this but until someone can demonstrate a straight-forward example of cursors being necessary (except for the case that I cited above) or even just better than other options, I cannot see the point any longer.

    For now, I regard them as an unnecessary evil.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]