• Jeff Moden (3/10/2008)


    Ok... once you learn how to use a Cursor, THEN avoid them as if they were Leprosy 😉 There is very very little you actually need a cursor for in the line of production code and then it needs to be a "firehose" cursor.

    ..in which case you might be better off doing that in a procedural language... Yes I said it.

    But first - work at the problem as if Cursors don't exist. There's a lot of power included in set-based processing, and it usually just takes a little "letting go" to get it to work. You don't need to tell SQL server "how" to do something - just tell it "what" to do, and "what" rows you need that done to, and voila - mostly set-based by then. All that extra control is stuff for procedural code - NOT set-based.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?