1

How to find last non-numeric character in a string such as "10jnklgm51". In order to find 'm' in the example what is the best simple way?

web surfer
  • 13
  • 1
  • 3

1 Answers1

7

The last non-numeric character is the first non-numeric character in the reverse string. So, something like this:

select substring(reverse(str),
                 patindex('%[^0-9]%', reverse(str)),
                 1)
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786