There Must Be 15 Ways To Lose Your Cursors... part 1, Introduction

  • phil.wood 94423

    Old Hand

    Points: 335

    I agree - don't awaken the beast.

    In the eyes of developers, cursors are like Marmite.

  • RBarryYoung

    SSC Guru

    Points: 143327

    ZZZZZZZZZZZZZZZZZZZZZZ ... mmha grmmah mrmma ... ZZZZZZZZZZZZZZZZZZZZ

    [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]

  • mschroeppel

    Valued Member

    Points: 53

    I also found this article rather insulting. I almost never use cursors. In fact, I think I should use them more. I sometimes find myself dong mental jujitsu, trying to write set-based T-SQL, when the task lends itself more easily to procedural code.

    Of course they are slower, but sometimes performance is not as important as writing something that is simple and easily maintainable. Arguing that programmers are lazy and dumb is all the more reason to write something in a way that your (lazy, dumb) successors will understand.

    Obviously anyone reading this article is interested in avoiding cursors, so why start off with a self-indulgent rant? JMHO.

  • Mike C

    SSC-Insane

    Points: 23224

    mschroeppel (7/4/2010)


    I also found this article rather insulting. I almost never use cursors. In fact, I think I should use them more. I sometimes find myself dong mental jujitsu, trying to write set-based T-SQL, when the task lends itself more easily to procedural code.

    Of course they are slower, but sometimes performance is not as important as writing something that is simple and easily maintainable. Arguing that programmers are lazy and dumb is all the more reason to write something in a way that your (lazy, dumb) successors will understand.

    Obviously anyone reading this article is interested in avoiding cursors, so why start off with a self-indulgent rant? JMHO.

    Set-based processing does stretch the old brain cells a bit, but as you point out everyone understands a loop.

    I just had a recent discussion with a group about the benefits of writing extremely simplistic code versus efficiency (and several other programming oddities, btw). I listed out several coding priorities and challenged them to put their coding priorities in the correct order for their business. If you try this exercise and "efficiency" is at the bottom of the list, then you obviously have to code to your priorities.

    Mike C

  • jadhavdileep2008

    Newbie

    Points: 3

    RBarryYoung - Monday, April 13, 2009 10:26 PM

    Comments posted to this topic are about the item There Must Be 15 Ways To Lose Your Cursors... part 1, Introduction

    I need quary for show customer I'd, capitalized first and last names, day and month (DD-MON) of date of birth and change the alias name DOB of female customers

  • Jeff Moden

    SSC Guru

    Points: 994284

    jadhavdileep2008 - Wednesday, January 9, 2019 7:04 AM

    RBarryYoung - Monday, April 13, 2009 10:26 PM

    Comments posted to this topic are about the item There Must Be 15 Ways To Lose Your Cursors... part 1, Introduction

    I need quary for show customer I'd, capitalized first and last names, day and month (DD-MON) of date of birth and change the alias name DOB of female customers

    You should start a new thread.  People will pay more attention to it and you won't be diluting someone else's discussion.  Since you're brand new to this forum, consider studying the article at the first link under "Helpful Links" in my signature line below.  I'd also recommend you be prepared to demonstrate what you're tried because it's not our job to help you make a living by writing code for you. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
    "If you think its expensive to hire a professional to do the job, wait until you hire an amateur."--Red Adair
    "Change is inevitable... change for the better is not."
    When you put the right degree of spin on it, the number 3|8 is also a glyph that describes the nature of a DBAs job. 😉

    Helpful Links:
    How to post code problems
    Create a Tally Function (fnTally)

Viewing 6 posts - 376 through 381 (of 381 total)

You must be logged in to reply to this topic. Login to reply