Questions tagged [isnumeric]

Determines whether an expression is a valid numeric type.

Syntax

ISNUMERIC ( expression )

Remarks

ISNUMERIC returns 1 when the input expression evaluates to a valid numeric data type; otherwise it returns 0. Valid numeric data types include the following:

enter image description here

Example

USE AdventureWorks2012;
GO
SELECT City, PostalCode
FROM Person.Address 
WHERE ISNUMERIC(PostalCode)<> 1;
GO

Note

For, SQL Server 2012+ use TRY_PARSE instead as ISNUMERIC is treating as numbers some not numeric values:

SELECT ISNUMERIC('123') as '123'
      ,ISNUMERIC('abc') as 'abc'
      ,ISNUMERIC('-') as '-'
      ,ISNUMERIC('+') as '+'
      ,ISNUMERIC('$') as '$'
      ,ISNUMERIC('.') as '.'
      ,ISNUMERIC(',') as ','
      ,ISNUMERIC('\') as '\'

enter image description here


Helpful links

191 questions
2
votes
2 answers

Excel sum if isnumber for non-contiguous range

I simply want to sum two cells if at least one of them is a valid number, or display blank if neither of them are. What is the best way to do this? I have read about SUMPRODUCT and tried to use ISERROR to no avail. What I finally came up with…
user3925803
  • 3,115
  • 2
  • 16
  • 25
2
votes
2 answers

Check if a string contains number or is numeric - Thymeleaf

Is there a way to check if string is numeric. {#strings.isNumeric(dataField)} doesn't work. How can I check if string contains numbers (specific number of digits as well) - is there a RegEx that can be used, or an inbuilt function that can be…
Loser Coder
  • 2,338
  • 8
  • 42
  • 66
2
votes
3 answers

is_numeric function is giving unexpected results

I wrote the following php code, the expected out put is "is not a number" because e is present in the string. But I got the output "is number".…
omrehman
  • 107
  • 3
  • 13
2
votes
4 answers

how to check if a string contains only numeric numbers in vba

I want to parse out the year info from a string like this one $8995 Apr 18 2008 Honda Civic Hybrid $8995 (Orem) pic map cars & trucks - by owner Since I retrieve this string online, sometimes the year element is not at the same place. The way I do…
TitanTheYaphet
  • 113
  • 1
  • 4
  • 15
2
votes
1 answer

SQL Query varchar field with numeric search

I created a table that had a nvarchar field named 'Notes', which people can enter whatever they want (number or text) to help for their searching. For example Table "Customer" ID Name Notes 1 AAA 1234 2 BBB 1235 3 CCC 1236 4 DDD …
2
votes
4 answers

Get null if non numeric or the actual numeric value in TSQL

I'm trying to get the numeric value of a string if isnumeric() function returns 1 or NULL if it returns 0. But I only get if it's numeric I get 1 or null if non numeric. Is it possible to return the numeric value (instead of 1) using something like…
Vladimir
  • 196
  • 3
  • 3
  • 12
2
votes
1 answer

IsNumeric equivalent in Linq

I need to use a function in Linq that equivalent to IsNumeric function in SQL. What I am trying to do is get codes that matches a common pattern. The codes should be unique and they are generated by code. The pattern is like…
Ahmet Keskin
  • 1,025
  • 1
  • 15
  • 25
2
votes
2 answers

Classic ASP IsNumeric weirdness?

Just ran into a rather strange bit of functionality with the baked in IsNumeric function is classic ASP. I had a JSONArray class that prints out its contents to a string - it was using IsNumeric to determine whether or not to escape values with "'s.…
FlyingStreudel
  • 4,434
  • 4
  • 33
  • 55
2
votes
2 answers

Varchar to Numeric conversion - CLR or 'e0'

I want to convert data from Varchar column to Numeric data type - so before conversion I am calling ISNUMERIC function to check whether data is numeric and if yes convert it to numeric data type. But I am facing an issue - IsNumeric function is not…
inutan
  • 10,558
  • 27
  • 84
  • 126
1
vote
3 answers

Arithmetic overflow error converting varchar to data type numeric

First, let me state I have read various similar posts and haven't been able to identify the similarities between the problem that other posters have had with this error message and the situation I've encountered. Perhaps I'm not searching…
akousmata
  • 1,005
  • 14
  • 34
1
vote
4 answers

How do I use JavaScript for number formatting?

I want to use JavaScript to restrict input on a text box to currency number formatting. For example: As given above, the text box should accept only numbers, commas and a period. But, after the…
Gnaniyar Zubair
  • 8,114
  • 23
  • 61
  • 72
1
vote
2 answers

While loop input int validation

I’m having a problem with my code. my while loop 3 times when its meant to loop once i've tried everything i know and it's not working import java.util.Scanner; public class validInput { public static void main (String[] args) { Scanner…
1
vote
3 answers

Why does IsNumeric() return False when given a number from a text line

I am working on some python code that will evaluate each line of a file, and if that line is a number, it should return false and ignore that line. This code comes from https://github.com/geoff604/sbv2txt/blob/master/README.md and I am working to…
user3324136
  • 415
  • 5
  • 20
1
vote
2 answers

Getting Error : 'int' object has no attribute 'isnumeric'

I was writing a code to get a student grade point average but I got an error. here is the piece of my code getting error : scoreinput=input("Score lesson: ") while True: if scoreinput.isnumeric(): scoreinput=int(scoreinput) if…
QuicKiller
  • 13
  • 4
1
vote
2 answers

Why does is_numeric() return false when passed a seemingly numeric string?

I am trying to understand numeric strings in PHP. I have the following code: var_dump(5 * "10 abc"); var_dump(is_numeric("10 abc")); Which gives me the output: int(50) bool(false) This confuses me as the string "10 abc" seems to be interpreted as…
Bradley
  • 369
  • 5
  • 11