Spilt List Function

  • This must be much simplier than I'm making it...

    I have an unique idenifier for a person, and a space delimited field containing grades they teach, since they could teach more than one grade I'm looking to have their unique idenifier and a single grade taught. I have a split list function but how do I do this...

    SELECT ID,

    (SELECT * FROM dbo.udfSplitList(Grades,' ')

    FROM TableA

    I know this is the wrong way and I get errors, any guidance would be great!

    Thanks!

  • eagb (2/14/2013)


    This must be much simplier than I'm making it...

    I have an unique idenifier for a person, and a space delimited field containing grades they teach, since they could teach more than one grade I'm looking to have their unique idenifier and a single grade taught. I have a split list function but how do I do this...

    SELECT ID,

    (SELECT * FROM dbo.udfSplitList(Grades,' ')

    FROM TableA

    I know this is the wrong way and I get errors, any guidance would be great!

    Thanks!

    First, you really should provide the details of the error(s) you are getting. It really doesn't tell us anything when all you say is "I get errors."

    Second, it looks like dbo.udfSplitList is a table valued function. This is how you should be using it in this case:

    SELECT

    a.ID,

    sl.* -- not sure what the column or columns returned are or I would list them.

    FROM

    TableA a

    CROSS APPLY SELECT * FROM dbo.udfSplitList(Grades,' ') sl

  • Thank you that worked perfectly!

  • eagb (2/14/2013)


    Thank you that worked perfectly!

    Any chance of us getting a peek at your split 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)

Viewing 4 posts - 1 through 3 (of 3 total)

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