Stripping a string

  • I have a field that contains data in this format: 'souph-0-97'

    What I need to do is bring back just the numbers after the second hyphen. Any suggestions?

  • Use the REVERSE function to turn the string around, then SUBSTRING based on the position of the now first hypen and REVERSE it back:

    select reverse(substring(reverse('souph-0-97'),1,charindex('-',reverse('souph-0-97'))-1))

    Jeremy

  • Another thought, if you know that there are always 2 digits, you could use the RIGHT function:

    select right('souph-0-97',2)

  • Jeremy,

    You're right on LOL I was just returning to say that I figured it out and that was the exact solution I got...thanks though!

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

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