Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get only numeric column values?

Tags:

sql-server

Using SQL Server 2005

I want to get only numeric values from the table

Column1

12345 asdf 2312 ase acd ..., 

Tried Query

Select Isnumeric(column1) from table 

Showing Result as

1 0 1 0 0 .., 

I need the colum1 numeric value

Need SQL Server Query help

like image 776
Gopal Avatar asked Dec 07 '09 09:12

Gopal


People also ask

How do I select only numeric values in SQL?

SQL Server ISNUMERIC() Function The ISNUMERIC() function tests whether an expression is numeric. This function returns 1 if the expression is numeric, otherwise it returns 0.

How do I select only numeric columns from a data frame?

To select columns that are only of numeric datatype from a Pandas DataFrame, call DataFrame. select_dtypes() method and pass np. number or 'number' as argument for include parameter.


1 Answers

SELECT column1 FROM table WHERE ISNUMERIC(column1) = 1 

Note, as Damien_The_Unbeliever has pointed out, this will include any valid numeric type.

To filter out columns containing non-digit characters (and empty strings), you could use

SELECT column1 FROM table WHERE column1 not like '%[^0-9]%' and column1 != '' 
like image 96
Breandán Avatar answered Sep 29 '22 16:09

Breandán