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
3
votes
3 answers

Fastest way to check if a character is a digit?

I am having issues with sqlserver's ISNUMERIC function where it is returning true for ',' I am parsing a postal code and trying to see if the second char (supposed to be a digit) is a 0 or not and do something different in each case. The issue is…
Mike
  • 8,137
  • 6
  • 28
  • 46
3
votes
2 answers

How do I make IsNumeric check the whole string/variable instead of just the first character?

I am using IsNumeric to check if a part of a variable are numbers or not. Unfortunately it only seems to check the first character of the string part instead of the whole bit. It currently accepts i.e. Q123 1234567 and QWER 1QWERTYR (and other…
Davey
  • 35
  • 5
3
votes
2 answers

Is there a built-in function to test for alpha or numeric data in Informix 7.3?

I have been searching around for a SQL function that tests a value for being alpha or for being numeric. There doesn't seem to be any functions like this for Informix 7.3, but I might have missed something or have been searching for the wrong…
CheeseConQueso
  • 5,831
  • 29
  • 93
  • 126
3
votes
1 answer

IsNumeric does not work in SQL server

Getting very annoyed with this simple query... I need to add an offset to a varchar, if it's a number and do nothing is it is not. For this reason I've created the following function in SQL-server. I then extract the answer with: select…
Johan
  • 74,508
  • 24
  • 191
  • 319
3
votes
2 answers

Delete Column Rows with Any Numeric Substrings

I notice that when an element of a column from a Pandas DataFrame has numeric substrings, the method isnumeric returns false. For example: row 1, column 1 has the following: 0002 0003 1289 row 2, column 1 has the following: 89060 324 123431132 row…
spacedustpi
  • 351
  • 5
  • 18
3
votes
2 answers

PHP Manual: Number Conversion in Is_Numeric Example 1?

I ran across this example in the PHP documentation:
sadq3377
  • 827
  • 1
  • 5
  • 17
3
votes
4 answers

PHP - usage of is_numeric() necessary, or can use comparison signs work for all positive numeric cases?

It seems that simple comparison signs >,>= and their reverse components can evaluate if a certain variable is a number or not. Example $whatami='beast'; ($whatami<0)?echo 'NaN':echo 'is numeric!'; Are there cases where is_numeric() usage is…
ina
  • 19,167
  • 39
  • 122
  • 201
3
votes
2 answers

Delete row if first cell isn't numeric vba Excel

I am using following code to delete a row if the first cell is not a number (text or blank cell) Dim LR3 As Long, i3 As Long With Sheets("Productos") LR3 = Range("A" & Rows.Count).End(xlUp).Row For i3 = LR3 To 2 Step -1 If…
agustin
  • 1,311
  • 20
  • 42
2
votes
4 answers

unable to determine if a string is currently an integer or not

The following funciton drove me nuts. How on earth 100x could be equal to 100 and then 100x is reported as an integer? For the life of me, I cannot figure it out. You can copy and paste the whole thing and see it for yourself. I'm missing a simple…
Average Joe
  • 4,521
  • 9
  • 53
  • 81
2
votes
1 answer

Query using a derived table with ISNUMERIC results in conversion failure (varchar to int)

Here's an example query: DECLARE @table table (loc varchar(10)) INSERT INTO @table VALUES ('134a'), ('123'), ('abc'), ('124') SELECT * FROM ( SELECT * FROM @table WHERE ISNUMERIC(loc) = 1 ) as a WHERE CAST(loc as INT) BETWEEN 100 AND 200 If…
MikeM
  • 27,227
  • 4
  • 64
  • 80
2
votes
1 answer

Wrong result from IsNumeric() in VB.NET

I have a function in VB.NET that loops through values and attempts to convert it to a decimal if IsNumeric is True, Dim Value As String If IsNumeric(Value) = True Then Rate = CType(Value, Decimal) <--- bombing here End If I've found that when…
2
votes
4 answers

What is taking IsNumeric() so long in .NET?

Was doing some benchmarking with IsNumeric today and compared it to the following function: Private Function IsNumeric(ByVal str As String) As Boolean If String.IsNullOrEmpty(Str) Then Return False Dim c As Char For i As Integer = 0 To…
Magnus Engdal
  • 5,446
  • 3
  • 31
  • 50
2
votes
6 answers

c++ isalnum endless loop

Greetings! Lets cut the excessive intro this time and get straight to the point. I have a problem in C++ using the isalnum method. the code: int playAgainst = 0; do { cout << "Who do you want to play against?(1/2)\n"; cout << "1: Human…
Joey Roosing
  • 2,145
  • 5
  • 25
  • 42
2
votes
1 answer

VBA IsNumeric fails on specific strings?

Can anyone please help tell me why below expression in immediate box shows the result as True? ? IsNumeric("1d11") ? IsNumeric("5000d110") Thank you. Lei
Zhou Lei
  • 23
  • 6
2
votes
3 answers

Best way to check if value is integer ? Coldfusion 9

I have fields to test and make sure they only accept integers. There is few functions but I wasn't sure which one is the best. First I tried isValid("integer",value) but I have discovered that "1,5" will be accepted as an integer. So then I tried…
espresso_coffee
  • 5,980
  • 11
  • 83
  • 193
1 2
3
12 13