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.
| Author |
Topic |
|
Amethystium
Aged Yak Warrior
701 Posts |
Posted - 2005-01-06 : 04:40:00
|
Greetings! ... and a happy new year to most but not all when I run this :select distinct isnumeric(totunits)from hmmemyrwhere totunits is not null I get a distinct value of 1, BUT when I do :select convert(money, totunits)from hmmemyrwhere totunits is not null I get a Error converting data type varchar to numeric.what is going on?! I know that you have not seen my data but surely if the ISNUMERIC function is able to convert all the values, hence the single value of 1 returned then all my varchar values should be converted no?------------->>> BREAKING NEWS!!! <<<------------- Saddam Hussien has weapons of mass destrcution  |
|
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2005-01-06 : 05:03:47
|
| isnumeric() is a boolean function..completely baffled by your question..H.N.Y.! |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2005-01-06 : 05:27:16
|
| probably some totunits are not valid money values?i tried this:declare @m varchar(10)set @m='20.0'select convert(money,@m)--------------------keeping it simple... |
 |
|
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2005-01-06 : 05:37:42
|
| or..bol says: ... can be converted to one of these data types.not to any of them.so, what if we try to convert(money,'5e+111') |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-01-06 : 06:41:01
|
| isnumeric doesn't tell you that a value can be converted to money.e.g. '1e2' is a valid numeric but cannot be converted to money (without some intermediate work).==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
Amethystium
Aged Yak Warrior
701 Posts |
Posted - 2005-01-06 : 09:58:13
|
Ok.. I get it now. Cheers!------------->>> BREAKING NEWS!!! <<<------------- Saddam Hussien has weapons of mass destrcution |
 |
|
|
SQLMike
Starting Member
7 Posts |
Posted - 2005-01-06 : 20:01:14
|
| I don't like that IsNumberic('5.') returns a true but Convert(int,'5.') says it can't be done. I would like Convert to at least check that the decimal part is something other than 0 before reporting an error. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-01-07 : 00:45:24
|
| Again - isnumeric does not tell you if something can be converted to an int. see my previous posy and read in bol about what the function does.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|