Isaac
Lifelong Learner
- Local time
- Yesterday, 23:28
- Joined
- Mar 14, 2017
- Messages
- 10,839
This may not be a big challenge for some of you. I've looked at charindex, substring, but cannot quite get it without looping (which I don't want to do).
I have text in a column like this:
asdf asdf # asdf asdf asdf
or
asdf asdf # to # asdf asdf asdf
I want to STRIP AWAY (remove) everything after the final number - whether that be the 1st (and only) number, or the 2nd (and final) number. There will only be 2 numbers max.
So I want those above examples to be converted to, respectively:
asdf asdf #
asdf asdf # to #
So find the second number and only return the text through that point. Or said another way, from the right side, find the first number you come to as you go left and strip that away
Looking for a way to do this in T-SQL
I think I might be able to get this if I tried hard enough, but my brain is extremely tired and so far I have NOT had any luck. Please assist if you can, thank you!
I have text in a column like this:
asdf asdf # asdf asdf asdf
or
asdf asdf # to # asdf asdf asdf
I want to STRIP AWAY (remove) everything after the final number - whether that be the 1st (and only) number, or the 2nd (and final) number. There will only be 2 numbers max.
So I want those above examples to be converted to, respectively:
asdf asdf #
asdf asdf # to #
So find the second number and only return the text through that point. Or said another way, from the right side, find the first number you come to as you go left and strip that away
Looking for a way to do this in T-SQL
I think I might be able to get this if I tried hard enough, but my brain is extremely tired and so far I have NOT had any luck. Please assist if you can, thank you!
Last edited: