Method for checking whether the value of a field is a number in SQL Server

Time:2021-11-20

Recently, there is a project that needs to check whether the value of a character field is a number. Because the data line is massive, it needs to be screened through SQL statements. Here is a memo.

The function used is IsNumeric. The specific statements are as follows:

Copy codeThe code is as follows:
SELECT *
From table
Where IsNumeric (field name to be checked) = 0

ISNUMERIC 

  Determines whether the expression is a valid numeric type.  
  
  grammar  
  ISNUMERIC   (   expression   ) 
  
  parameter  
  expression 
  
  The expression to evaluate.  
  
  Return type  
  int 
  
  notes  
  When the input expression gets a valid integer, floating point number, money    or    decimal    Type, then    ISNUMERIC    return    1; Otherwise return    0 The return value is    one    Make sure you can    expression    Convert to one of the above numeric types.