user2927086
user2927086

Reputation: 101

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?

Upvotes: 8

Views: 79709

Answers (2)

Naveen Kumar Alone
Naveen Kumar Alone

Reputation: 7678

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 )

Upvotes: 37

Tim Schmelter
Tim Schmelter

Reputation: 460258

The function's name is ISNUMERIC:

SELECT CustomerName 
FROM CUSTOMER_TABLE 
WHERE CustomerId IS NOT NULL 
AND ISNUMERIC( CustomerName ) = 0

Sql-Fiddle

Upvotes: 10

Related Questions