Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server is not numeric and not null

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?

like image 984
user2927086 Avatar asked Oct 29 '13 13:10

user2927086


People also ask

Is not numeric in SQL Server?

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.

How do you check whether a value is numeric or not in SQL?

The ISNUMERIC() function tests whether an expression is numeric. This function returns 1 if the expression is numeric, otherwise it returns 0.

Is is not NULL and != The same in SQL?

<> 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.

IS NOT NULL () in SQL?

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.


1 Answers

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 )

like image 148
Naveen Kumar Alone Avatar answered Oct 20 '22 06:10

Naveen Kumar Alone