Finally a technical blog. J
I had used IsNumeric functions of MSSQL in my stored proc. I was supposed to do some other actions based on the results of IsNumeric function.
If IsNumeric(@var)=1
Select ‘True’
Else
Select ‘False’
Surprising and shockingly I found strange results. Here’s the sample. Note down your answers before you check the output of the below 3 statements.
Select IsNumeric(‘1D’)
Select IsNumeric(‘D1’)
Select IsNumeric(‘1D1’)
Yes, the SQL treats ‘1D1’ as numeric.
This happens with only 2 letters ‘D’ and ‘E’.
If the entire string which is used for check has only one character and that one character is either ‘D’ or ‘E’ then the string is considered as numeric.
I am not very sure about the reason behind this behavior of SQL.
If anyone has answer for this please comment it to my post.
1 comment:
Mystery about d and e: The d(D) and e(E) are used in Fortran to denote a float double precision (d), respectively exponential writing (e). SQL Server internally uses the standard C++ function ATOF() to parse strings and ATOF follows Fortran rules. So SQL interprets is wrongly.
Solution: Wrap a SP on top of IsNumeric
Ref: http://classicasp.aspfaq.com/general/what-is-wrong-with-isnumeric.html
-Gladiator
Post a Comment