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
919
votes
26 answers

Identify if a string is a number

If I have these strings: "abc" = false "123" = true "ab2" = false Is there a command, like IsNumeric() or something else, that can identify if a string is a valid number?
Gold
  • 60,526
  • 100
  • 215
  • 315
236
votes
40 answers

jQuery: what is the best way to restrict "number"-only input for textboxes? (allow decimal points)

What is the best way to restrict "number"-only input for textboxes? I am looking for something that allows decimal points. I see a lot of examples. But have yet to decide which one to use. Update from Praveen Jeganathan No more plugins, jQuery has…
wenbert
  • 5,263
  • 8
  • 48
  • 77
90
votes
10 answers

Checking if string is numeric in dart

I need to find out if a string is numeric in dart. It needs to return true on any valid number type in dart. So far, my solution is bool isNumeric(String str) { try{ var value = double.parse(str); } on FormatException { return false; }…
scrblnrd3
  • 7,228
  • 9
  • 33
  • 64
58
votes
25 answers

T-sql - determine if value is integer

I want to determine if a value is integer (like TryParse in .NET). Unfortunatelly ISNUMERIC does not fit me because I want to parse only integers and not every kind of number. Is there such thing as ISINT or something? Here is some code to make…
zafeiris.m
  • 4,339
  • 5
  • 28
  • 41
52
votes
8 answers

How can you tell if a value is not numeric in Oracle?

I have the following code that returns an error message if my value is invalid. I would like to give the same error message if the value given is not numeric. IF(option_id = 0021) THEN IF((value<10000) or (value>7200000) or /* Numeric Check…
Kyle Williamson
  • 2,251
  • 6
  • 43
  • 75
50
votes
11 answers

How do you test your Request.QueryString[] variables?

I frequently make use of Request.QueryString[] variables. In my Page_load I often do things like: int id = -1; if (Request.QueryString["id"] != null) { try { id =…
Ian G
  • 29,468
  • 21
  • 78
  • 92
46
votes
12 answers

PHP is_numeric or preg_match 0-9 validation

This isn't a big issue for me (as far as I'm aware), it's more of something that's interested me. But what is the main difference, if any, of using is_numeric over preg_match (or vice versa) to validate user input values. Example One:
no.
  • 2,356
  • 3
  • 27
  • 42
39
votes
7 answers

An improved isNumeric() function?

During some projects I have needed to validate some data and be as certain as possible that it is javascript numerical value that can be used in mathematical operations. jQuery, and some other javascript libraries already include such a function,…
Xotic750
  • 22,914
  • 8
  • 57
  • 79
20
votes
11 answers

Efficient ISNUMERIC() replacements on SQL Server?

So I just spent 5 hours troubleshooting a problem which turned out to be due not only to the old unreliable ISNUMERIC but it looks like my problem only appears when the UDF in which ISNUMERIC is declared WITH SCHEMABINDING and is called within a…
Cade Roux
  • 88,164
  • 40
  • 182
  • 265
16
votes
7 answers

Most elegant isNumeric() solution for java

I'm porting a small snippet of PHP code to java right now, and I was relying on the function is_numeric($x) to determine if $x is a number or not. There doesn't seem to be an equivalent function in java, and I'm not satisfied with the current…
Doug
  • 1,446
  • 4
  • 14
  • 26
12
votes
5 answers

ISNUMERIC('07213E71') = True?

SQL is detecting that the following string ISNUMERIC: '07213E71' I believe this is because the 'E' is being classed as a mathmatical symbol. However, I need to ensure that only values which are whole integers are returned as True. How can I do this?
Curtis
  • 101,612
  • 66
  • 270
  • 352
9
votes
4 answers

T-SQL IsNumeric() and Linq-to-SQL

I need to find the highest value from the database that satisfies a certain formatting convention. Specifically, I would like to find the highest value that looks like EU999999 ('9' being any digit) select max(col) will return something like…
cdonner
  • 37,019
  • 22
  • 105
  • 153
8
votes
2 answers

IsNumeric failing with "A severe error occurred on the current command." SQL Server 2014 CTE

I'm running a series of scripts which generate a database. They run to completion on SQL Server 2012 (11.0.5058.0). On SQL Server 2014 (12.0.4213.0) a script errors with: Msg 0, Level 11, State 0, Line 0 A severe error occurred on the current…
npjohns
  • 2,218
  • 1
  • 17
  • 16
8
votes
3 answers

What is a reliable isnumeric() function for python 3?

I am attempting to do what should be very simple and check to see if a value in an Entry field is a valid and real number. The str.isnumeric() method does not account for "-" negative numbers, or "." decimal numbers. I tried writing a function for…
texasman1979
  • 473
  • 1
  • 6
  • 17
8
votes
1 answer

IsNumeric function not working correctly

I have very strange problem with IsNumeric function in classic asp fail. Something like this happens in my code: Response.write Score // 79.617 Response.write IsNumeric(Score) // false Response.write IsNumeric("79.617") //…
gotqn
  • 42,737
  • 46
  • 157
  • 243
1
2 3
12 13