|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
IsNumeric Function Question?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
http://www.aspfaq.com/show.asp?id=2390
--
Show quote
Jacco Schalkwijk SQL Server MVP "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 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 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 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) 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) On Mon, 3 Oct 2005 16:34:47 -0400, JT wrote:
>But the following: Hi JT,>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() 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) |
|||||||||||||||||||||||