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
1
vote
0 answers

Problems with is_numeric validation

I am attempting to validate numeric data before adding it to a database, but for some reason it is not triggering the condition for the error message in either positive or negative logic. I can put letters and special characters in, and the code…
1
vote
2 answers

SQL Server 2008 R2 data type conversion error

I have a column of data type varchar, some of which contain numerical (decimal) values. I need to find all rows with numerical values > 100. I'm using ISNUMERIC to filter rows that contain numbers, after which I'm trying to use CAST or CONVERT to…
1
vote
3 answers

Finding Max Value of an nvarchar column in sql server 2012 using LINQ

I have a table full of serial numbers of a product, the datatype is nvachar, i have entries like 1001, 1002, 1003, abc001, efg002, 1004, def222 . I have to return the max value of the valid numeric numbers in the column, in this case output should…
1
vote
1 answer

Test is_int doen't work after passing $_POST var in simple $var

Is someone can explain me this..: $bob = $_POST['foo'] ; is_int($bob) FAIL but is_numeric($bob) is OK . So i know i cannot use is_int directly on $_POST but here i transfert the post value in another variable before.. Whats wrong please ?!
albator
  • 859
  • 1
  • 10
  • 18
1
vote
4 answers

PHP: Why is True a Number but not Numeric?

So I'm trying to understand WHY this occurs: "; if (is_numeric($a)){ echo "a is numeric
"; } echo "b is ".$b."
"; if (is_numeric($b)){ echo "b is numeric
"; } ?> gives…
EnglishAdam
  • 1,380
  • 1
  • 19
  • 42
1
vote
2 answers

Using is_numeric for form validation

I have some links structured as follows... http://domain.com?problem_id=23&course_id=4 The expected values from the GET "fields" (problem_id and course_id) are to be integers. Can I validate this data by simply saying... if…
gtilflm
  • 1,389
  • 1
  • 21
  • 51
1
vote
2 answers

jquery hide extra dropdowns in a table

I have several tables on a page with the possibility of multiple dropdowns in each table. The table and the dropdowns are autogenerated. The tables I want to target have numeric ids and all of the values of the dropdowns will be numeric. HTML…
jessier3
  • 809
  • 1
  • 7
  • 16
1
vote
2 answers

IsNumeric() not working with Request.QueryString

I'm having problems trying to get IsNumeric to work properly with Request.QueryString. The server is Windows 2008 R2 / IIS7.5 My code could not be any simpler: <%@ LANGUAGE=VBScript %> <% Response.Write "IsNumeric: " &…
Rich
  • 378
  • 7
  • 18
1
vote
3 answers

PHP form validation where value is not null

When attempting to validate a field, it doesn't seem to work. I need to only perform !is_numeric when $postcode is not null. I do have client side validation, but I want to ensure that I have server side validation too. code: else…
DLO
  • 309
  • 2
  • 7
  • 17
1
vote
4 answers

PHP: how to force property of method to be integer?

My current way: class A { public function function_b($myint) { if (!is_numeric($myint)) return false; // code ... } } I would like to abandon the function is_numeric() like this: public function function_b(Integer $myint)…
Mr. B.
  • 8,041
  • 14
  • 67
  • 117
1
vote
5 answers

changing a word in a string?

I have this assignment: Write a function smallnr(x) that takes a number x and if x is an integer between 0 and 6 it returns the name of the number, otherwise it simply returns x as a string. I did the following: def smallnr(x): if x>6: …
user1718623
  • 13
  • 1
  • 3
1
vote
3 answers

Safe casting VARCHAR to DECIMAL in Teradata

In Teradata DB I have source table create set table SRC_TABLE ( Some_Id varchar(2O) not null ); This table is loaded with data from external system. I have target table create set table DST_TABLE ( Some_Id decimal(4,0) not null ); I need…
JohnyCash
  • 399
  • 1
  • 4
  • 9
0
votes
2 answers

jQuery - Setting .blur to a class

I'm trying to set a blur on all 'number' classes (which happen to be tags). My trial coding is; $('.number').blur(function () { if ($.isNumeric($(this).val) == false) alert('false ' + $(this).val); else alert('true ' +…
Simon R
  • 3,732
  • 4
  • 31
  • 39
0
votes
3 answers

Using 2 functions at the same time to validate form

im trying to put to javascript functions that will validate a form, but cant make it work. This is what i have :