SQL Server 2000
SELECT ISNUMERIC('.')
Returns 1
Why would a single period evaluate to being numeric? Is this a flaw?There has been ambiguity about this function for some time. According to BOL
it must be able to be evaluated to a valid integer, floating point number,
money or decimal data type. We can see that the '.' character works for
money, although not decimal, so is therefore (using definition above)
designated as numeric. Perhaps then the question becomes should it be
allowed to be casted into a money datatype? In the same way we could argue
for/against '', '$', '+' etc.
select cast('.' as money)
select cast('.' as decimal(10,5))
SELECT ISNUMERIC('.')
I'd be interested in the history of this one - why '.' is a valid money
value but not a valid decimal. Maybe something to do with old accounting
systems.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .|||I think that it is a flaw. I tried casting '.' to integer and decimal and
got an error.
Russel Loski, MCSD.Net
"Izzy" wrote:
> SQL Server 2000
> SELECT ISNUMERIC('.')
> Returns 1
> Why would a single period evaluate to being numeric? Is this a flaw?
>|||The thing that makes is valid (according to the definition in BOL) is that
it can be casted to the money datatype. So, according to the BOL definition
it is correct, but we could discuss the ability to run:
select cast('.' as money)
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .|||I understand why that returns 0.00, but you would think at least one
numerical digit would have to be present on either side of the decimal
point before SQL Server would allow the cast operation to complete
successfully.
The issue I had was trying to convert char(11) data to INT. Maybe I
should just write my own function and call it ISINT(), and have the
function return either a 0 or 1.
Does anyone have a function like that already written?
Paul Ibison wrote:
> The thing that makes is valid (according to the definition in BOL) is that
> it can be casted to the money datatype. So, according to the BOL definitio
n
> it is correct, but we could discuss the ability to run:
> select cast('.' as money)
> Cheers,
> Paul Ibison SQL Server MVP, www.replicationanswers.com .|||I suggest the following article:
http://classicasp.aspfaq.com/genera...-isnumeric.html
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de
--|||LOL, I like the names of the new functions "IsReallyNumeric", too
funny.
Thanks for the suggestion.
Jens wrote:
> I suggest the following article:
> http://classicasp.aspfaq.com/genera...-isnumeric.html
> HTH, Jens K. Suessmeyer.
> --
> http://www.sqlserver2005.de
> --sql
No comments:
Post a Comment