How to write SQL Query to get desire output-1

Hello guys, as I know you all are technology lovers and you would like my this question.

I have a question as below:

I have a table created as

create table #t1 (name varchar(50))

insert into #t1 values('123'),
('xyz'),
('pqr'),
('456'),
('789')

DROP TABLE #t1

I want the records which are having only numeric name in the table, I have two simple different ways to do which areĀ as below:

  1. SELECT * FROM #t1 WHERE name not like ‘%[^0-9]%’
  2. SELECT * FROM #t1 WHERE ISNUMERIC(name)=1

Please run both of these query on SQL FIDDLER

Please write another ways to achieve same result. This is the challenge for you. All technology thirsty guys could find new ways to do and post the answer.

Leave a Reply