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
 easy text parsing question, extract 119.00(USD)

Author  Topic 

sqlchiq
Posting Yak Master

133 Posts

Posted - 2008-10-20 : 13:05:06
I have columns in the following format

119.00(USD)
19.00(USD)
119.65(USD)


etc

I need just the number value.

119
19
119

etc

I know this is an easy one, but I cant get it to work for some reason...

sqlchiq
Posting Yak Master

133 Posts

Posted - 2008-10-20 : 13:11:50
its not working for me because

CHARINDEX(column, '.')

is returning all 0s for me
Go to Top of Page

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2008-10-20 : 13:12:10
select left(col1,charindex('.',col1)-1)
Go to Top of Page

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2008-10-20 : 13:12:53
quote:
Originally posted by sqlchiq

its not working for me because

CHARINDEX(column, '.')

is returning all 0s for me



CHARINDEX('.', column) you had it the other way around :)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-20 : 13:14:46
Also

SELECT CAST(REPLACE(col,'(USD)','') AS int)
Go to Top of Page
   

- Advertisement -