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
0
votes
1 answer

SQL Server - Add Constraint for existing table using Alter Table function

I got a little trouble with SQL. This is the table Customers : ID Name Address Phone KP001 Bill Jl Bali NO 27 81976524451 KP002 Jane Jl Sandang NO 5 81876537521 KP003 Dion Jl Kebon Jeruk NO 7…
0
votes
1 answer

SQL Server - Add Constraint using CHARINDEX and Isnumeric

I got a little trouble with SQL. This is the table Customers : ID Name Address Phone KP001 Bill Jl Bali NO 27 81976524451 KP002 Jane Jl Sandang NO 5 81876537521 KP003 Dion Jl Kebon Jeruk NO…
cindy
  • 35
  • 1
  • 3
  • 7
0
votes
1 answer

Change invalid textbox value - VB NET

I currently have 3 textboxes. Each textbox must contain a number. If any one of the three textboxes does not contain a numeric value, show an error message. For textboxes not displaying a number, (where IsNumeric returns false), I want to change its…
Chozo Qhai
  • 283
  • 2
  • 10
  • 19
0
votes
8 answers

Validate Integer in Form Input Using is_numeric

In my form, a team's score is input, validated by the PHP script and then passed to the MySQL database. However, I want to make sure that a positive integer is being submitted, so there are no problems on the back-end when league standings are…
712Jefferson
  • 211
  • 2
  • 7
  • 17
0
votes
1 answer

ISNUMBER() validation rule for numbers

I am trying to add a new validation rule ISNUMBER(number) on a number type field. but it seems like I can't because I got a syntax error, Error: Incorrect argument type for function 'ISNUMBER()' How could I validate this field and check if it's a…
hasan.alkhatib
  • 1,509
  • 3
  • 14
  • 28
0
votes
3 answers

Mysql how is ISNUMERIC() available?

In MSSQL i am using query like below, and it will make different queries depending what i have in $search: text or numbers. $query=" IF (isnumeric('$search')=0) SELECT * FROM giper …
Sergii Rechmp
  • 309
  • 1
  • 6
  • 16
0
votes
5 answers

intval or is_numeric? PHP

i am fetching a text from mysql database and i get it by ID in the url: site.php?id=1 and so on What is considered to be most safe to prevent sql injection and stuff. Is this way correct:
Elijah
0
votes
5 answers

Check $_POST['id'] is numeric then do this if not do otherwise

Hello I seemed to be failing my code: if (!empty($_POST['id'])) { echo "empty"; } else { if (is_numeric($_POST['id'])) { echo "numeric!"; } else { echo "not empty but not numeric how come?"; } } My browser url:…
The Wolf
  • 195
  • 3
  • 16
0
votes
2 answers

Validating Textboxs

I am doing a simple aplication using Windows Forms and I have a question... My form has 15 textboxs and I want to validate everyone using the event KeyPress or validating. I have this code that is working: If Not IsNumeric(txtn1.Text) Then e.Cancel…
Jean Paul CP
  • 253
  • 2
  • 10
0
votes
3 answers

Any Reason Why IsNumeric() Fails On A Number?

I currently have this line of code which has been working for the past 6 months: If IsNumeric(txtProductID.Text) Then ...do stuff Else Dim msg As String = "Error!" End If All of the sudden, no matter what kind of entry is put in txtProductID…
Jason
  • 51,583
  • 38
  • 133
  • 185
0
votes
1 answer

Improve performance using IsNumeric function in loop which is exeecute 1 to 1 caror or more in VB.net

I have one function which is written in VB.net, Code is look like below. For rowIndex As Integer = 0 To nRows - 1 Dim max As Integer = -1 Dim arrTemp() As String arrTemp = Nothing For columnIndex As Integer = 0 To…
Mohmedsadiq
  • 133
  • 1
  • 10
0
votes
2 answers

is_numeric($str) for database queries

Basically my question is, if I have a number string, and i'm going to compare it to the database, is that a secure/safe way to check. Or should I just escape my number variables aswell as my strings (like I already do)? Example:
Jake
  • 1,469
  • 4
  • 19
  • 40
-1
votes
1 answer

Is PHP's is_numeric() function effective against directory traversal attacks?

I would like to know if the code below is SECURE and not that it is a good or bad practice, since I want to report if it is vulnerable to directory traversal attack. I do not think if this question is duplicated! I am working on a penetration…
-1
votes
3 answers

Check string in an array

I have strings stored in an array and need to check if the 5th character of each string is a number or not. The code I used is: If Mid(arr(i), 5, 1) = IsNumeric(True) Then MsgBox("Number") End If It is giving an error: An unhandled exception…
Subi
  • 3
  • 1
  • 4
-1
votes
1 answer

isnumeric with bug?

Execute command bellow in SQl Server 2014. select ISNUMERIC('1E234') -- return 1 select ISNUMERIC('1E2341') -- return 0 I expect that the first select returns 0 My solution: -- if return 0 is numeric select…
Rodrigo
  • 7
  • 1
1 2 3
12
13