Select only integers from char column using SQL Server

SELECT * FROM POWDER WHERE IsNumeric(Name) = 1

IsNumeric returns 1 for some other characters that are valid in numbers, such as + and - and $ but for your input you should be fine.


Try this:

SELECT * FROM Table WHERE Name LIKE '[0-9]%%'


To avoid issues with ISNUMERIC and all spaces, -, +, . etc, use the fact that the column is char(5)

SELECT * 
  FROM POWDER
 WHERE Name LIKE '[0-9][0-9][0-9][0-9][0-9]'

Edit: for any number of characters. Double negative...

SELECT * 
  FROM POWDER
 WHERE Name NOT LIKE '%[^0-9]%'