22,210
社区成员
发帖
与我相关
我的任务
分享
select case when isnumeric(col) = 1 then 1 else 0 end
from
(
select 'aaa' as col union all
select '111'union all
select '4'
) a
===
=======
0
1
1
--两个都行!
select case when col like '%[0-9]%' then 1 else 0 end
from
(
select 'aaa' as col union all
select '111'union all
select '4'
) a
select case when col like '%[0-9]%' then 1 else 0 end from tb
--竟然忘了还有isnumeric........
select isnull(nullif(isnumeric([Field]),1),[Field])
from [Table]
select
case when isnumeric(col)=1 then col else 0 end
from
tb
SELECT CASE WHEN ISNUMERIC(COL)=0 THEN 0 ELSE COL END AS COL FROM TB
select case when isnumeric([Field])=1 then [Field] else 0 end
from [Table]
select case when ISNUMERIC(col)=1 then col else 0 end
from tb
isnumeric()
SELECT CASE WHEN ISNUMERIC(TYPE)=0 THEN 1 ELSE 0 END
FROM A
---返回1或0(数据型)
select isnumeric(1)
--返回1或0(表示是不是日期型)
select isdate(1)
--判断字段是否为数字 是数字把数据返回,不是的话返回0
drop table tb;
create table tb(colname varchar(10));
insert into tb(colname)
select
'luoyoumou' union all select
'123' union all select
'123ab4';
select (case when isnumeric(colname)=1 then colname else 0 end) as is_num
from tb;
--------------------------------------------------------
0
123
0
--判断字段是否为数字 是数字把数据返回,不是的话返回0
select (case when isnumeric(colname)=1 the colname else 0 end) as is_num
from tb;
select case when col like '%[0-9]%' then 1 else 0 end
from
(
select 'aaa' as col union all
select '111'union all
select '4' union all
select '4aaa'
) a