Splitting Strings in SQL Server 2016

  • Jeff Moden - Thursday, August 10, 2017 7:21 PM

    dbishop - Thursday, August 10, 2017 4:49 PM

    Maybe someone already brought it up, but I am a little curious as to why the OPENJSON function was even mentioned in this article. I can't see that it really added any value. It can't handle a straight delimited string without manipulating the string, even if that string is comma delimited (must add brackets, enclose each string in double-quotes, and escape existing double-quotes, and it is slower than STRING_SPLIT. The overhead involved in making a string compatible with using OPENJSON seems like making mention of it only fills the article with useless fluff. When you initially mentioned it, I was expecting to read some benefit of using it over STRING_SPLIT. Great for breaking down a JSON, but not for splitting strings.

    Otherwise, a good article.

    I can't actually speak for Wayne but I suspect that it's for the same reasons why I would include it and several other methods in such an article. A lot of people have come up with many different ways of splitting strings and I'd want to be sure to cover them all if, for nothing else, to demonstrate the fallacy of using some of those "clever" methods because other people writing about them don't.

    Like Jeff and Ed mentioned, OPENJSON was included since it can be used to split strings. As Jeff alluded to, people will use anything possible to do a task, and since it can be used, I wanted to cover it.
    I'm glad that you liked the article.

    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

  • xsevensinzx - Friday, August 11, 2017 6:15 AM

    Great article and read!

    thanks!

    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

  • Excellent, very interesting article. Thanks very much.

  • Thanks Andy

    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

Viewing 4 posts - 31 through 33 (of 33 total)

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