dopydb
SSCertifiable
Points: 6672
More actions
February 1, 2022 at 10:06 am
#3979503
hi folks
i am a bit stuck at extracting 2 characters before the last -
eg below i Want to extract AA
CL-318-AA-1.2
been trying a mixture of substring, char index statements, but just cant get it!
any ideas?
mr
February 1, 2022 at 10:11 am
#3979506
meant to say length is variable such as CL-318-AA-1.233
so i cant use SUBSTRING(REVERSE(part),5,2)
DesNorton
SSC-Insane
Points: 23842
February 1, 2022 at 10:25 am
#3979508
The following code should do the trick
SUBSTRING(part, LEN(part) - CHARINDEX('-', REVERSE(part)) -1, 2)
February 1, 2022 at 12:51 pm
#3979560
great stuff Des, perfect
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply