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) AI와 지속 가능한 엔지니어링 — 생성은 빠르게, 검증은 철저하게

영어 원문 : https://www.linkedin.com/pulse/ai-sustainable-engineering-generate-fast-verify-thoroughly-yoon-hclqf/ [공지 / 면책 조항] 이 글에 표현된 모든 견해는 전...