34,593
社区成员
发帖
与我相关
我的任务
分享
--当输入表达式的计算结果为有效的 numeric 数据类型时,ISNUMERIC 返回 1;否则返回 0
SELECT * FROM [表名] WHERE ISNUMERIC([列名])=1
select * from Customers where isnumeric(customerid)=1
--(2 行受影响)
select * from Customers where customerid not like '%[^1-9]%'
--(0 行受影响)
--这句貌似无效,我的是SQL2005
create table #tb(col varchar(10))
insert #tb
select 'A123' union
select 'B234D' union
select '123' union
select '567' union
select '567H'
select * from #tb where ISNUMERIC(col)=1
--或者
select * from #tb where col not like '%[^1-9]%'
/*
col
----------
123
567
(所影响的行数为 2 行)
*/
where isnumeric(colname)=1