Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Extracting the last value

Author  Topic 

pithhelmet
Posting Yak Master

183 Posts

Posted - 2002-12-24 : 08:47:03
Hi all -

I have a varchar that has a value like this....

Able, Clyde 339
Able, Clyde 7
Alford, James Austin 1034
Berry, Roy A. 624
Berry, Virgil B 882

I need to get the number from the end of the string...

Please advise on the best method for this...

thanks
tony



ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2002-12-24 : 09:13:16
If your format always has the number at the end and if there is a number there will be a space before it then here is a solution.

SELECT LTRIM(RIGHT(MyStringCol,CHARINDEX ( ' ' , REVERSE(MyStringCol))))
From MyTable


Go to Top of Page
   

- Advertisement -