日期:2014-05-18 浏览次数:20643 次
if object_id('tb') is not null
drop table tb
go
create table tb
(
id int identity(1,1),
col1 varchar(10)
)
go
insert into tb (col1)
select '1' union all
select '2' union all
select '你好' union all
select '3'
go
select sum(case when isnumeric(col1)=1 then col1 else 0 end) from tb
go
/*
-----------
6
(1 行受影响)
*/
------解决方案--------------------
是楼上的意思吗?
------解决方案--------------------
select sum(字段) from tb where partindex('%[^0-9]%',字段)=0