Problem with Query

  • ChandraMohan Nandula (7/23/2009)


    Hi Jeff,

    Thanks a lot for providing the solution. I will check it and revert back to you.

    Thanks, Chandra. I appreciate the feedback.

    --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.

    Change is inevitable... Change for the better is not.


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

  • . (7/24/2009)


    I just want to say again that your solution was really pretty Jeff. Mine was also based on a ctes using row_number(), but yours was much faster and more concise. I never thought to use row_number() twice in one statement.

    Thanks. Bob. I can't take the credit for it though. It's one of those nifty tricks that I recently learned (about 3 months ago). There was a post about someone winning a contest with that same method... it was the only thing that beat the "quirky" update method (it didn't win by much but has the advantage of being able to do it in a single query instead of using a temp table, meaning that it can be used in a view if necessary). It was one of the few times that I labeled someone's code as "freakin' brilliant". Obviously, I was greatly impressed.

    I'll see if I can find the URL that started it all on this method if you're interested.

    --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.

    Change is inevitable... Change for the better is not.


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

  • No need. I have already filed the solution you posted in my toolbox. Thanks 🙂

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Actually Jeff, please do post the url when you find it.

  • No, no, no. Don't post it whatever you do!!

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • .,.,., why not let Jeff post the url? Others, like myself, may just benefit ... oh, you want to keep us in the dark, like mushrooms! 😛

  • My wife phrases it "Keep us in the dark and feed us manure."

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Lynn Pettis (7/24/2009)


    .,.,., why not let Jeff post the url? Others, like myself, may just benefit ... oh, you want to keep us in the dark, like mushrooms! 😛

    Agh... he's just kidding...

    http://www.sqlmag.com/article/articleid/93462/sql_server_blog_93462.html identifies the problem

    http://www.sqlmag.com/Articles/ArticleID/93606/93606.html identifies the solution

    Anyone got some steak to go with those shrooms? 😛

    --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.

    Change is inevitable... Change for the better is not.


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

  • Jeff Moden (7/24/2009)


    Lynn Pettis (7/24/2009)


    .,.,., why not let Jeff post the url? Others, like myself, may just benefit ... oh, you want to keep us in the dark, like mushrooms! 😛

    Agh... he's just kidding...

    http://www.sqlmag.com/article/articleid/93462/sql_server_blog_93462.html identifies the problem

    http://www.sqlmag.com/Articles/ArticleID/93606/93606.html identifies the solution

    Anyone got some steak to go with those shrooms? 😛

    First, like duh... I know that.

    Second, I actually don't appreciate mushrooms, so I usually don't eat them unless my wife has cooked with them and chopped them small.

  • Hi,

    Thanks a lot Jeff and Lynn. It worked very well.

    [font="Verdana"]Thanks
    Chandra Mohan[/font]

  • You bet, Chandra... thanks for the feedback.

    --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.

    Change is inevitable... Change for the better is not.


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

Viewing 11 posts - 16 through 25 (of 25 total)

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