,case when LEN(b.BKTXT)>6 then 0
when ascii(dbo.f_RemoveChinese(b.BKTXT )) between 48 and 57 then cast(replace(dbo.f_RemoveChinese(b.BKTXT ),'-','') as int) --数字
when ascii(dbo.f_RemoveChinese(b.BKTXT )) between 65 and 123 then 0 --字母
when ascii(dbo.f_RemoveChinese(b.BKTXT )) > 123 then 0 --汉字
else 0
end as fj2
1.
sql语句判断是否为数字、字母、中文
select ascii(字段)
数字:48-57
字母:65-123
汉字:123+
如,要删除某个全为数字的字段
DELETE FROM table WHERE ascii(name) between 48 and 57
2.
一、包含中文字符
select * from 表名 where 列名 like '%[吖-座]%'
二、包含英文字符
select * from 表名 where 列名 like '%[a-z]%'
三、包含纯数字
select * from 表名 where 列名 like '%[0-9]%'
删除中文函数:
CREATE FUNCTION f_RemoveChinese
(
@str VARCHAR(500)
)
RETURNS VARCHAR(500)
AS
BEGIN
-- '%[0-9]%' 所有數字
-- '%[A-Za-z]%' 所有字母
-- '%[A-Za-z0-9]%' 所有數字與字母
-- .... 組合使用,依此類推
WHILE PATINDEX('%[吖-咗]%',@str) > 0
SET @str = STUFF(@str,PATINDEX('%[吖-咗]%',@str),1,'')
RETURN @str
END
GO
标签:中文,RemoveChinese,dbo,--,server,BKTXT,str,sql,ascii From: https://blog.51cto.com/u_512327/5933756