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
 General SQL Server Forums
 New to SQL Server Programming
 update

Author  Topic 

a.ashabi
Posting Yak Master

117 Posts

Posted - 2008-10-15 : 04:21:02
hi.I have a field with some values like this:

Nutricology/allergy Research Group Nanotek Chitosan 60 caps 32977
Now Stevia Extract 8 oz. 18391
Now Mung Beans 1 lb 21929

I need the numbers on the last part:

32977
18391
21929

thanks.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-15 : 04:23:42
SELECT REVERSE(LEFT(REVERSE(col),CHARINDEX(' ',REVERSE(col))-1)) AS YourValue FROM Table
Go to Top of Page

a.ashabi
Posting Yak Master

117 Posts

Posted - 2008-10-15 : 04:35:42
thank u so much for yr quick reply :)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-10-15 : 05:06:16
Simply

SELECT right(col,charindex(' ',reverse(col))-1)AS YourValue FROM Table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-10-15 : 05:20:21
SELECT RIGHT(Col, 5)
FROM Table1

???



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-15 : 05:28:54
quote:
Originally posted by Peso

SELECT RIGHT(Col, 5)
FROM Table1

???



E 12°55'05.63"
N 56°04'39.26"



Will work unless you've numbers having more than 5 digits appearing at the end. As per sample output this is fine though.
Go to Top of Page
   

- Advertisement -