AppDividend
Latest Code Tutorials

SQL ISNUMERIC Function Example

SQL ISNUMERIC is an inbuilt function that is used to check whether the expression passed as an input is the valid number or not. The ISNUMERIC() function returns 1 if the expression is a valid number. Otherwise, it returns 0.

SQL ISNUMERIC

SQL ISNUMERIC function tests whether the expression is numeric. The ISNUMERIC() function accepts an expression and returns 1 if the expression is a valid numeric type; otherwise, it returns 0.

Syntax

ISNUMERIC (Expression);

Parameters

Expression: The expression is to be checked, whether it is a valid number or not.

The function checks whether the expression entered can be converted to a numeric datatype or not.

Note that a valid numeric type is one of the following:

Exact numbers: BIGINT, INT, SMALLINT, TINYINT, and BIT

Fixed precision: DECIMAL, NUMERIC

Approximate: FLOAT, REAL

Monetary values: MONEY, SMALLMONEY

Query 1

SELECT ISNUMERIC (9876);

Output

1

Explanation

The expression entered is already in the numeric form. So, the function returned 1 as an output.

Query 2

SELECT ISNUMERIC (‘9876’);

Output

1

Explanation

The expression was in string format, which, when converted implicitly to numeric form, returned a valid number. So, the function returned 1 as an output.

Query 3

SELECT ISNUMERIC (10*5);

Output

1

Explanation

The arithmetic expression, when executed, returned a valid number. Thus, the function returned 1 as an output.

Query 4

SELECT ISNUMERIC (‘AppDividend.Com’);

Output

0

Explanation

The expression was in string format, which, when tried to be converted implicitly to numeric form, didn’t return a valid number. So, the function returned 0 as an output.

Query 5

SELECT ISNUMERIC (‘2020-02-28’);

Output

0

Explanation

The expression was in datetime format, which cannot be converted to numeric form. So, the function returned 0 as an output.

Finally, SQL ISNUMERIC Function Example is over.

See also

SQL SYSTEM_USER

SQL USER_NAME

SQL CURRENT_USER

SQL ISNULL

SQL CHOOSE

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.