Search code examples
sqlsql-serversql-server-2008slashisnumeric

ISNUMERIC on VARCHAR Column returning numbers still?


Why does ISNUMERIC = 0 return numbers with spaces and '/' ? This is SQL Server 2008 R2 BTW

Thanks Guys,

Code Sample:

  SELECT A AS 'VARCHARCOLUMN' FROM TABLE
    WHERE ISNUMERIC(A) = 0

    TABLE Structure:
    ----------------------
        A  |   B    |   C   |
    ----------------------
      x    |        |       |
      .    |        |       |
      p    |        |       |
     1 7/2 |        |       |
     15.   |        |       |
      5    |        |       |


      Result set:
   ----------------------
        A  |   B    |   C   |
    ----------------------
      x    |        |       |
      p    |        |       |
     1 7/2 |        |       | <- Why is this returned???

Solution

  • The IsNumeric function in SQL Server only returns true when the expression is a valid numeric type. It doesn't understand that the expression is 1 and seven eighths. It sees this as a string. MSDN IsNumeric Reference