t-sql 2012 split function

  • How about I point you here: http://www.sqlservercentral.com/articles/Tally+Table/72993/

  • How about what is wrong with what I just submitted? The splitter function works for everything else at my company. I would like to know why it does not work for me.
    I am suppose to use the splitter logic I should you since that is a company standard to use it.

  • Not sure, the following works for me:

    declare @ssGrade VARCHAR(8000) = 'PK,KG,01,02';
    SELECT * FROM fn_splitString(@ssGrade);

    Doing the insert into a temp table works as well.

  • wendy elizabeth - Tuesday, December 19, 2017 2:02 PM

    How about what is wrong with what I just submitted? The splitter function works for everything else at my company. I would like to know why it does not work for me.
    I am suppose to use the splitter logic I should you since that is a company standard to use it.

    It depends.  Can you post the code for the fn_splitString function, please because there might actually be something very wrong with it, especially if it's the function I'm thinking of.

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

  • Hmm.

    What do you get from the following queries?

    SELECT * FROM Enrollment WHERE Grade IN ('PK','KG','01','02')
    SELECT Grade, COUNT(*) FROM Enrollment GROUP BY Grade

    Thomas Rushton
    blog: https://thelonedba.wordpress.com

  • I was able to use your split function without issue based on what you posted.  What is happening when you use it?

  • Jeff Moden - Thursday, December 21, 2017 6:23 PM

    wendy elizabeth - Tuesday, December 19, 2017 2:02 PM

    How about what is wrong with what I just submitted? The splitter function works for everything else at my company. I would like to know why it does not work for me.
    I am suppose to use the splitter logic I should you since that is a company standard to use it.

    It depends.  Can you post the code for the fn_splitString function, please because there might actually be something very wrong with it, especially if it's the function I'm thinking of.

    Ah... sorry... I missed where you've already posted it.  If it were a snake, it would have bitten me. 

    As Lynn says,

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

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