Tally OH! An Improved SQL 8K “CSV Splitter” Function

  • Comments posted to this topic are about the item Tally OH! An Improved SQL 8K “CSV Splitter” Function

    --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, I had to rate this article 5 stars, because that's as high as the ratings allow. It deserves a 15!

    BTW, I'm aghast --- you've actually used a SQL CLR now! 😀 It would be nice if we could get Paul to contribute it, and to have it added to the resources of this article.

    Again, excellent job. Extremely well done, and extremely thorough. Thank you so much for this article, and for the new DelimitedSplit8K function.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • Thanks Jeff. It's great to walk with you through your beer-popsicle thought process, and for all the work you did here.

    I thought I was the only one who would sit in the corner with the dust bunnies.... 🙂

    I still want to shoot CLR though.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • WayneS (5/1/2011)


    Jeff, I had to rate this article 5 stars, because that's as high as the ratings allow. It deserves a 15!

    BTW, I'm aghast --- you've actually used a SQL CLR now! 😀 It would be nice if we could get Paul to contribute it, and to have it added to the resources of this article.

    Again, excellent job. Extremely well done, and extremely thorough. Thank you so much for this article, and for the new DelimitedSplit8K function.

    I couldn't have done it without the help of you, Ron, and Paul. All 3 of you did some awesome work with testing and verification of the code. You guys ROCK!

    So far as the CLR goes... yeah, I know I stuck my toe into the other world, but I had to know if the new function even came close. Paul was very cool in his understanding that I don't even know how to spell "C" and he made it real easy for me to install. 🙂

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

  • Craig Farrell (5/1/2011)


    Thanks Jeff. It's great to walk with you through your beer-popsicle thought process, and for all the work you did here.

    I thought I was the only one who would sit in the corner with the dust bunnies.... 🙂

    I still want to shoot CLR though.

    Heh... dust bunnies know so much! 😛 Thanks for the feedback, Craig.

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

  • WayneS (5/1/2011)


    Jeff, I had to rate this article 5 stars, because that's as high as the ratings allow. It deserves a 15!

    BTW, I'm aghast --- you've actually used a SQL CLR now! 😀 It would be nice if we could get Paul to contribute it, and to have it added to the resources of this article.

    Again, excellent job. Extremely well done, and extremely thorough. Thank you so much for this article, and for the new DelimitedSplit8K function.

    Jeff let me second WayneS statement.... and add it was an honor and privilege to work for you on the testing.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • bitbucket-25253 (5/1/2011)


    WayneS (5/1/2011)


    Jeff, I had to rate this article 5 stars, because that's as high as the ratings allow. It deserves a 15!

    BTW, I'm aghast --- you've actually used a SQL CLR now! 😀 It would be nice if we could get Paul to contribute it, and to have it added to the resources of this article.

    Again, excellent job. Extremely well done, and extremely thorough. Thank you so much for this article, and for the new DelimitedSplit8K function.

    Jeff let me second WayneS statement.... and add it was an honor and privilege to work for you on the testing.

    Thanks for all the help testing, Ron. You did a great job. Heh... and no dust bunnies where actually injured during any of the tests. 😀

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

  • Very thorough analysis. Great job!

    Take care,

    Solomon...

    SQL#https://SQLsharp.com/ ( SQLCLR library ofover 340 Functions and Procedures)
    Sql Quantum Lifthttps://SqlQuantumLift.com/ ( company )
    Sql Quantum Leaphttps://SqlQuantumLeap.com/ ( blog )
    Info sitesCollations     •     Module Signing     •     SQLCLR

  • Solomon Rutzky (5/1/2011)


    Very thorough analysis. Great job!

    Take care,

    Solomon...

    [font="Verdana"]

    But it seems at least a week long activity !!!

    😛

    Goodish!

    [/font]

  • All these methods use CHARINDEX to efficiently see where the next delimiter is. But what about handling CSV strings with quoted text, e.g. where "John Smith","23, The High Street","Sometown" has to be split into 3 strings? Do you have a good method for this sort of data?

    (This is why I prefer tab separated to comma separated, with all its different ways to handle embedded comas, but usually you have to process the client's data as they give it to you, not as you'd like it :rolleyes: )

  • Jeff, your article is great!

    The final splitter function could have been 3 times slower than the original one, and the article would have been memorable anyway. It's a tale of stubborn resistance to surrender and a "thinking outside the box" lesson for all of us.

    Thank you very much.

    -- Gianluca Sartori

  • Just wanted to add my 2 cents as well. Very well done. I will be adding these routines to my toolbox as well.

    I'm curious, I'm wondering if I could make them work in Oracle as well. Maybe I'll give it a shot when I have some time.

  • Awesome article. Thanks for the effort, Jeff.

  • Solomon Rutzky (5/1/2011)


    Very thorough analysis. Great job!

    Take care,

    Solomon...

    Thanks for stopping by, Solomon. 🙂

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

  • Abrar Ahmad_ (5/2/2011)


    Solomon Rutzky (5/1/2011)


    Very thorough analysis. Great job!

    Take care,

    Solomon...

    [font="Verdana"]

    But it seems at least a week long activity !!!

    😛

    Goodish!

    [/font]

    Heh... it seemed like a year to me. Thanks for stopping by, Abrar. 🙂

    --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 15 posts - 1 through 15 (of 990 total)

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