How to retrieve only integer values from SQL Server

sql, sql-server, sql-server-2008-r2, t-sql

Solution

Taking both most upvoted answer on the duplicate target and removing a `.` from the code, plus a comment from that answer to Why are non-digits LIKE [0-9]?, the accurate answer to this question about integers is this:

SELECT Name
FROM tbl_data
WHERE Name NOT LIKE '%[^0123456789]%' COLLATE Latin1_General_CS_AS

Problem

How to retrieve only the integer value from this column? My table: ``` CREATE TABLE tbl_data ( [Name] nvarchar(max) ) INSERT INTO tbl_data VALUES ('Nikesh'), ('113'), ('sunam'), ('sudhir'), ('2.30'), ('ankit'), ('675') ``` Output I need: ``` Name ----- 113 675 ```

Original source

Related problems