sum函数,该如何解决

sum函数表中的某一列有数字,有汉字(nvarchar)。如何过滤出数字记录并计算它们的和。[解决办法]怎么过滤?[解

sum函数
表中的某一列有数字,有汉字(nvarchar)。如何过滤出数字记录并计算它们的和。

[解决办法]
怎么过滤?
[解决办法]

SQL code
if object_id('tb') is not null   drop table tbgocreate table tb( id int identity(1,1), col1 varchar(10))goinsert into tb (col1)select '1' union allselect '2' union allselect '你好' union allselect '3'goselect sum(case when isnumeric(col1)=1 then col1 else 0 end) from tbgo/*-----------6(1 行受影响)*/
[解决办法]
是楼上的意思吗?
[解决办法]
select sum(字段) from tb where partindex('%[^0-9]%',字段)=0