SQL 查询汉字的首字母
2009-06-08 16:24
323 查看
create function fun_getPY(@str nvarchar(4000)) returns nvarchar(4000) as begin declare @word nchar(1),@PY nvarchar(4000) set @PY='' while len(@str)>0 begin set @word=left(@str,1)--截取一个字符串出来 --如果非汉字字符,返回原字符 set @PY=@PY+(case when unicode(@word) between 19968 and 19968+20901 then (select top 1 PY from ( --他的主要思想就是unicode值的一个比较 如果在范围之内就---返回相应的字母 select 'A' as PY,N'驁' as word union all select 'B',N'簿' union all select 'C',N'錯' union all select 'D',N'鵽' union all select 'E',N'樲' union all select 'F',N'鰒' union all select 'G',N'腂' union all select 'H',N'夻' union all select 'J',N'攈' union all select 'K',N'穒' union all select 'L',N'鱳' union all select 'M',N'旀' union all select 'N',N'桛' union all select 'O',N'漚' union all select 'P',N'曝' union all select 'Q',N'囕' union all select 'R',N'鶸' union all select 'S',N'蜶' union all select 'T',N'籜' union all select 'W',N'鶩' union all select 'X',N'鑂' union all select 'Y',N'韻' union all select 'Z',N'咗' ) T where word>=@word collate Chinese_PRC_CS_AS_KS_WS order by PY ASC) else @word end) set @str=right(@str,len(@str)-1) --把字符串的最前面一个字符串截取了 end return @PY end
相关文章推荐
- SQL汉字首字母查询处理用户定义函数
- 数据库sql如何查询某个字段只含有数字和字母或者是汉字
- sql中根据汉字的拼音首字母查询的函数
- sql查询utf-8字段中包含非汉字的记录和大小写字母转换
- SQL 查询汉字的首字母
- 【很好的方法记录下来】sql中怎么根据汉字的拼音首字母查询?
- SQL汉字首字母查询处理用户定义函数
- sql查询汉字首字母
- sql中怎么根据汉字的拼音首字母查询
- sql中根据汉字的拼音首字母查询的函数
- 查询汉字首字母和查询是否包含中文字符
- SQL:汉字转换拼音或拼音首字母
- 按汉字首字母排序(sql语句)
- mysql实现汉字首字母查询
- sql语句-按照汉字拼音首字母排序
- 在DB2 中创建一个获取汉字拼音首字母的SQL 函数
- sql 汉字转首字母拼音
- SQL将汉字转化为拼音(首字母、全拼)
- jquery AutoComplete 兼容汉字首字母 MVC2进行查询
- sql语句按照汉字拼音首字母排序