写成了一个function
/*@str 需要获取汉字的字符串*/
create function CharRep(@str nvarchar(200))
returns nvarchar(200)
as
begin
declare @i int, @char nvarchar(1), @zh nvarchar(200)
set @i = 1
set @zh = ''
while @i <= len(@str)
begin
set @char = substring(@str, @i, 1)
if unicode(@char) between 19968 And 40869
set @zh = @zh + @char
set @i = @i + 1
end
return @zh
end
执行 select dbo.CharRep(&#39;侬好a/bc 侬好&#39;)
结果 a/bc
附:
unicode编码范围:
汉字:[0x4e00,0x9fa5](或十进制[19968,40869])
数字:[0x30,0x39](或十进制[48, 57])搜索
小写字母:[0x61,0x7a](或十进制[97, 122])
大写字母:[0x41,0x5a](或十进制[65, 90])