Inserting a value in an ordered string

  • Jeff Moden (1/13/2009)


    Mark,

    VERY clever code... I obviously never thought of using PatIndex and a variable for the first character of a range... And, it's about twice as fast as the Tally table method.

    The very cool part is that it's twice as fast as that if you take it out of the UDF and use the code inline.

    Thanks for the feedback, much appreciated.

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537
  • Mark,

    My apologies. When I ran your code I had declared the existing string parameter as char instead of varchar. The code works great!

    Thanks again.

    S Ely

  • Sorry for the name gaff Jeff,

    I must be getting old ....

    Cheers!

    Sergei

  • Nice one Mark...

    Rarely see someone outdo Jeff ....:)

    "Keep Trying"

  • Sergei Ely (1/13/2009)


    Sorry for the name gaff Jeff,

    I must be getting old ....

    Cheers!

    Sergei

    No problem, Sergei... that's the whole idea, isn't get? Get older? 😀

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

  • Chirag (1/13/2009)


    Nice one Mark...

    Rarely see someone outdo Jeff ....:)

    ... and Mark knocked this one out of the park! 🙂 Nicely done, Mark.

    --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 6 posts - 16 through 21 (of 21 total)

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