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

  • Jeff Moden

    SSC Guru

    Points: 993892

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

  • WayneS

    SSC Guru

    Points: 95339

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


    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[/url], How to ask a question, Performance Problems[/url], Common date/time routines,
    CROSS-TABS and PIVOT tables Part 1[/url] & [url url=http://www

  • Evil Kraig F

    SSC Guru

    Points: 100851

    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

  • Jeff Moden

    SSC Guru

    Points: 993892

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

  • Jeff Moden

    SSC Guru

    Points: 993892

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

  • Ron McCullough

    SSC Guru

    Points: 63877

    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]

  • Jeff Moden

    SSC Guru

    Points: 993892

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

  • Solomon Rutzky

    SSCoach

    Points: 15939

    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 sites — Collations     •     Module Signing     •     SQLCLR

  • Abrar Ahmad_

    SSCarpal Tunnel

    Points: 4104

    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]

  • David Data

    SSCrazy

    Points: 2965

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

  • spaghettidba

    SSC Guru

    Points: 105661

    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.

  • Lynn Pettis

    SSC Guru

    Points: 442116

    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.

  • Geoff A

    SSChampion

    Points: 11407

    Awesome article. Thanks for the effort, Jeff.

  • Jeff Moden

    SSC Guru

    Points: 993892

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

  • Jeff Moden

    SSC Guru

    Points: 993892

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

Viewing 15 posts - 1 through 15 (of 948 total)

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