Results 1 to 11 of 11
  1. #1
    Join Date
    May 2002
    Location
    Montréal, Canada
    Posts
    28

    Unanswered: some SPLIT function?

    Hi there,

    I have a text field containing data like:

    val_field
    _________________
    val1,val2,val3,val4
    val1,val2,val5

    I would like to make a kind of split function, something I would have wrote like this:

    SELECT SPLIT(val_field,',') FROM myTable WHERE val_field = 'val1,val2,val5'

    Would return:
    ______
    val1
    val2
    val5

    Then I could turn it in a stored proc in a way to send me back multi-recordset result, that's no problem.

    I'm sure there's a way to split a string with a separator, just can't figure out how to do it.

    Thanks!
    Data Climber

  2. #2
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    809
    look at the CHARINDEX in Books Online.
    Paul Young
    (Knowledge is power! Get some!)

  3. #3
    Join Date
    May 2002
    Location
    Montréal, Canada
    Posts
    28
    Originally posted by Paul Young
    look at the CHARINDEX in Books Online.
    This can be a good start to extract delimiters position before substracting values. I'm gonna work on that and publish result when it will work, this will make a usefull feature.

    Thanks Paul.
    Data Climber

  4. #4
    Join Date
    Jun 2002
    Posts
    1
    Originally posted by Paul Young
    look at the CHARINDEX in Books Online.
    You should be able to use DECODE to get multiple recordsets.

  5. #5
    Join Date
    May 2002
    Location
    Montréal, Canada
    Posts
    28
    Originally posted by mdb
    You should be able to use DECODE to get multiple recordsets.
    Do you have an example on how to use this?
    Data Climber

  6. #6
    Join Date
    Feb 2002
    Posts
    2,232
    This is what you are looking for:

    split function

  7. #7
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    809
    DECODE is available in Oracle NOT MS Sql.
    Paul Young
    (Knowledge is power! Get some!)

  8. #8
    Join Date
    May 2002
    Location
    Montréal, Canada
    Posts
    28
    Originally posted by rnealejr
    This is what you are looking for:

    split function
    exactly!!! It sounds like someone already did the job. Let me apply it and I'll give you news about it.

    Thanks everybody for help!
    Data Climber

  9. #9
    Join Date
    May 2003
    Posts
    12

    Is there anything like DECODE in MS SQL?

    Originally posted by Paul Young
    DECODE is available in Oracle NOT MS Sql.
    Does anyone know, is there a method similar to the functionality of the DECODE statement provided by PL/SQL in MS SQL???

  10. #10
    Join Date
    May 2003
    Posts
    12

    Re: Is there anything like DECODE in MS SQL?

    Originally posted by lisa.shores
    Does anyone know, is there a method similar to the functionality of the DECODE statement provided by PL/SQL in MS SQL???
    Nevermind...i found the answer here!

    http://www.sqlmag.com/Forums/message...&threadid=3005

  11. #11
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    149
    Equivalent of decode in SQL Server is CASE statement

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •