Home All Groups Group Topic Archive Search About

IsNumeric Function Question?

Author
30 Sep 2005 3:51 PM
Uday
Hi all,

Please take a look the queries below:

select isNumeric('0000E000110') as IsNum

IsNum      
-----------
1

(1 row(s) affected)


select isNumeric('0000D000110') as IsNum

IsNum      
-----------
1

(1 row(s) affected)

select isNumeric('0000A000110') as IsNum

IsNum      
-----------
0

(1 row(s) affected)

******************************************

Observation:

Is '0000E000110' or '0000D000110' a Numeric Value?

I tried this on all the SqlServer's that I have access to.....!! all say the
same.

Version I have is:
Microsoft SQL Server  2000 - 8.00.760

I am looking at it in a wrong direction or is it a bug?

Any comments are appreciated,
_Uday

Author
30 Sep 2005 3:56 PM
Jacco Schalkwijk
http://www.aspfaq.com/show.asp?id=2390

--
Jacco Schalkwijk
SQL Server MVP


Show quote
"Uday" <U***@discussions.microsoft.com> wrote in message
news:407F24A6-32C3-4A85-983D-BA5D4E2F9A68@microsoft.com...
> Hi all,
>
> Please take a look the queries below:
>
> select isNumeric('0000E000110') as IsNum
>
> IsNum
> -----------
> 1
>
> (1 row(s) affected)
>
>
> select isNumeric('0000D000110') as IsNum
>
> IsNum
> -----------
> 1
>
> (1 row(s) affected)
>
> select isNumeric('0000A000110') as IsNum
>
> IsNum
> -----------
> 0
>
> (1 row(s) affected)
>
> ******************************************
>
> Observation:
>
> Is '0000E000110' or '0000D000110' a Numeric Value?
>
> I tried this on all the SqlServer's that I have access to.....!! all say
> the
> same.
>
> Version I have is:
> Microsoft SQL Server  2000 - 8.00.760
>
> I am looking at it in a wrong direction or is it a bug?
>
> Any comments are appreciated,
> _Uday
Author
30 Sep 2005 3:57 PM
SQL
This just means it can be converted to a numeric data type
run this below
select convert(float,'0000D000110')  --will work
select convert(float,'0000A000110')  -- will not work


http://sqlservercode.blogspot.com/



Show quote
"Uday" wrote:

> Hi all,
>
> Please take a look the queries below:
>
> select isNumeric('0000E000110') as IsNum
>            
> IsNum      
> -----------
> 1
>
> (1 row(s) affected)
>
>
> select isNumeric('0000D000110') as IsNum
>
> IsNum      
> -----------
> 1
>
> (1 row(s) affected)
>
> select isNumeric('0000A000110') as IsNum
>
> IsNum      
> -----------
> 0
>
> (1 row(s) affected)
>
> ******************************************
>
> Observation:
>
> Is '0000E000110' or '0000D000110' a Numeric Value?
>
> I tried this on all the SqlServer's that I have access to.....!! all say the
> same.
>
> Version I have is:
> Microsoft SQL Server  2000 - 8.00.760
>
> I am looking at it in a wrong direction or is it a bug?
>
> Any comments are appreciated,
> _Uday
Author
30 Sep 2005 3:57 PM
Rick Sawtell
Take a look at:

http://www.aspfaq.com/show.asp?id=2390



Rick Sawtell
MCT, MCSD, MCDBA
Author
30 Sep 2005 4:01 PM
JT
What's even more surprising is that isnumeric('$') = 1.

Show quote
"Uday" <U***@discussions.microsoft.com> wrote in message
news:407F24A6-32C3-4A85-983D-BA5D4E2F9A68@microsoft.com...
> Hi all,
>
> Please take a look the queries below:
>
> select isNumeric('0000E000110') as IsNum
>
> IsNum
> -----------
> 1
>
> (1 row(s) affected)
>
>
> select isNumeric('0000D000110') as IsNum
>
> IsNum
> -----------
> 1
>
> (1 row(s) affected)
>
> select isNumeric('0000A000110') as IsNum
>
> IsNum
> -----------
> 0
>
> (1 row(s) affected)
>
> ******************************************
>
> Observation:
>
> Is '0000E000110' or '0000D000110' a Numeric Value?
>
> I tried this on all the SqlServer's that I have access to.....!! all say
> the
> same.
>
> Version I have is:
> Microsoft SQL Server  2000 - 8.00.760
>
> I am looking at it in a wrong direction or is it a bug?
>
> Any comments are appreciated,
> _Uday
Author
30 Sep 2005 9:25 PM
Hugo Kornelis
On Fri, 30 Sep 2005 12:01:09 -0400, JT wrote:

>What's even more surprising is that isnumeric('$') = 1.

Hi JT,

Why is that surprising?

SELECT CAST('$' AS money)

returns

---------------------
..0000



Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Author
3 Oct 2005 8:34 PM
JT
But the following:
SELECT CAST('$' AS int)
Returns this:
Syntax error converting the varchar value '$' to a column of data type int.

Calling a value "numeric" is too vague. Perhaps the function should be
re-named IsMoney()


Show quote
"Hugo Kornelis" <hugo@pe_NO_rFact.in_SPAM_fo> wrote in message
news:q9brj15dotj1mas9dh9g7lke869tgfm8g0@4ax.com...
> On Fri, 30 Sep 2005 12:01:09 -0400, JT wrote:
>
>>What's even more surprising is that isnumeric('$') = 1.
>
> Hi JT,
>
> Why is that surprising?
>
> SELECT CAST('$' AS money)
>
> returns
>
> ---------------------
> .0000
>
>
>
> Best, Hugo
> --
>
> (Remove _NO_ and _SPAM_ to get my e-mail address)
Author
3 Oct 2005 9:31 PM
Hugo Kornelis
On Mon, 3 Oct 2005 16:34:47 -0400, JT wrote:

>But the following:
>SELECT CAST('$' AS int)
>Returns this:
>Syntax error converting the varchar value '$' to a column of data type int.
>
>Calling a value "numeric" is too vague. Perhaps the function should be
>re-named IsMoney()

Hi JT,

That wouldn't do, since the function has been designed to test if the
value can be converted to at least one numeric type. From BOL:

ISNUMERIC returns 1 when the input expression evaluates to a valid
integer, floating point number, money or decimal type

Note the use of OR, where I would have prefered AND.

What is wrong with IsNumeric()?  http://www.aspfaq.com/show.asp?id=2390

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)

AddThis Social Bookmark Button