select CustomerName from CUSTOMER_TABLE where CustomerId IS NOT NULL
How can I get customer name if customer name is not numeric in SQL?
I tried to use IS NOT NUMERIC
, I get syntax error.
So how can I do this?
In SQL Server, you can use the ISNUMERIC() function to find out whether an expression is numeric or not. The function returns 1 if the expression is numeric, and 0 if it's not. To use this function, simply pass the value/expression to the function while calling it.
The ISNUMERIC() function tests whether an expression is numeric. This function returns 1 if the expression is numeric, otherwise it returns 0.
<> is Standard SQL-92; != is its equivalent. Both evaluate for values, which NULL is not -- NULL is a placeholder to say there is the absence of a value. Which is why you can only use IS NULL / IS NOT NULL as predicates for such situations.
The NOT NULL constraint enforces a column to NOT accept NULL values. This enforces a field to always contain a value, which means that you cannot insert a new record, or update a record without adding a value to this field.
Try with ISNUMERIC()
For example, from your query
SELECT CustomerName FROM CUSTOMER_TABLE
WHERE CustomerId IS NOT NULL AND ISNUMERIC(CustomerName) = 0
ISNUMERIC(expr.) determines whether an expression is a valid numeric type or not.
Syntax:
ISNUMERIC ( expression )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With