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 |
|
anandc
Starting Member
20 Posts |
Posted - 2005-12-13 : 06:51:15
|
| select isnumeric('-') returns 1 indicating valid numeric value, butselect cast('-' as numeric) returns Arithmetic overflow errorCould someone explain this behaviour of SQL server??Anand- Anand |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-12-13 : 07:04:03
|
i'd say it's a bug.BOL statesquote: ISNUMERIC returns 1 when the input expression evaluates to a valid integer, floating point number, money or decimal type; otherwise it returns 0. A return value of 1 guarantees that expression can be converted to one of these numeric types.
select isnumeric('-') , cast ( '-' as int) -- works , cast ( '-' as money) -- works , cast ( '-' as float) -- doens't work , cast ( '-' as numeric(12,2)) -- doens't work , cast ( '-' as decimal) -- doens't workGo with the flow & have fun! Else fight the flow |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
anandc
Starting Member
20 Posts |
Posted - 2005-12-13 : 07:24:17
|
quote: Originally posted by madhivanan Read this fullyhttp://aspfaq.com/show.asp?id=2390MadhivananFailing to plan is Planning to fail
Hi MadhivananI still can't understand why IsNumeric('-') should return 1. If it is like IsNumeric('-4') then its OK. Why IsNumeric of TAB & Carriage Return should return 1 ??- Anand |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2005-12-13 : 08:24:32
|
SQL Server ISNUMERIC will return a 1 for any string it can convert to a number. See the example below for -declare @x intselect @x ='-'select [@x] = @x@x ----------- 0(1 row(s) affected quote: Originally posted by anandcHi MadhivananI still can't understand why IsNumeric('-') should return 1. If it is like IsNumeric('-4') then its OK. Why IsNumeric of TAB & Carriage Return should return 1 ??- Anand
CODO ERGO SUM |
 |
|
|
Kristen
Test
22859 Posts |
|
|
|
|
|