Sunday, 14 June 2020

[SQL Server] Simple ISNUMERIC Test

[SQL Server] Simple ISNUMERIC Test

ISNUMERIC System function returns 1(true) when the expression is a valid numeric type.

Script
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
SELECT ISNUMERIC('1234') AS '1', 
       ISNUMERIC('A587') AS '2', 
       ISNUMERIC('222!') AS '3', 
       ISNUMERIC('123l123') AS '4', 
       ISNUMERIC('157.123') AS '5', 
       ISNUMERIC(NULL) AS '6', 
       ISNUMERIC('') AS '7', 
       ISNUMERIC('0') AS '8', 
       ISNUMERIC('12345678901234567890') AS '9', 
       ISNUMERIC('1234567890123456789012345678901234567890123456789012345678901234567890') AS '10', 
       ISNUMERIC('1.234567890123456789012345678901234567890123456789012345678901234567890') AS '11';

Result

Description
  1. Returns "1".
  2. Includes a character - A. Returns "0"
  3. Includes a special character - !. Returns "0"
  4. Includes a character (looks like 1, but it's not) - l. Returns "0"
  5. Returns "1"
  6. NULL does not regard as a numeric type. Returns "0".
  7. Blank does not regard as a numeric type. Returns "0".
  8. Returns "1".
  9. It's bigger than BIGINT type, but still a numeric type. Returns "1"
  10. Very big number(70 digits), but still a numeric type. Returns "1"
  11. 69 places of decimals, but still a numeric type. Returns "1"


Reference

No comments:

Post a Comment

(KOR)☁️ AWS Solutions Architect Associate 자격증 취득 여정

  !저의 경험 , 팁 , 그리고 SAA-C03 자격증 합격을 위한 노하우 공유! 조금 늦은 포스팅이지만 , 꼭 공유하고 싶었던 이야기입니다 . 회사 내 주변 동료들이 자주 이렇게 말하곤 했습니다 . “ 님 실...