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 2005 Forums
 Transact-SQL (2005)
 convert text field to numeric?

Author  Topic 

mapperkids
Yak Posting Veteran

50 Posts

Posted - 2007-04-10 : 14:15:09
In a table, I have one varchar field which is contain dollar values what I did is use the convert function in the select statement

Select * from TABLEA where CONVERT(money, VALUE_FIELD) > 1000

The problem is there are some record contain data is not valid for convertion, most likely is not number, so it give me errors during the convertion.

Is there any way I can find out exactly which records cause problem, so I can fix it manually.


Thanks!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-04-10 : 14:22:14
You can use the IsNumeric function to determine which ones are causing the conversion problems. Check out IsNumeric in BOL for more information.

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-04-11 : 09:07:28
1 Make sure you use proper datatype
2 Do currency formations at front end (If you use it)
3 ISNUMERIC is not always realiable
http://aspfaq.com/show.asp?id=2390
4 One of the methods is
Where col not like '%[^0-9]%'

Madhivanan

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

- Advertisement -