How to get only numbers in a column in SQL server? using ISNUMERIC function ?
Q How to get only numbers in a column in SQL server ?
Let me explain problem.
I have a table like this in this table the column(Pin No) have invalid data when i write a query i want only correct pin number rows how to do that.
i will use ISNUMERIC function to achieve this result .
Let me explain problem.
I have a table like this in this table the column(Pin No) have invalid data when i write a query i want only correct pin number rows how to do that.
i will use ISNUMERIC function to achieve this result .
ID | User_name | Pin no |
1 | Todd | 517408 |
2 | sara | Pin no |
3 | Mark | pin 516 |
4 | Kera | 506789 |
create a table in sql server:-
create table user (id int ,User_Name varchar(20), pinno varchar(7))
Go
insert into user values (1 ,'Todd', '517408')
insert into user values (2, 'sara', 'Pin no')
insert into user values (3, 'Mark', 'pin 516')
insert into user values (4, 'Kera', '506789')
write a query to get only correct pin number rows
select * from usser
where ISNUMERIC(pinno)=1
ISNUMERIC function will return number rows = 1 reming all =0
eg. select id , Usser_Name ,pinno, ISNUMERIC(pinno) as num from usse
Comments