网上关于获取中文字符首字母的SQL函数
来源:互联网 发布:java 简单加密 编辑:程序博客网 时间:2024/05/22 14:44
网上关于获取中文字符首字母的SQL函数
函数1:
create function f_GetPy(@str nvarchar(4000))
returns nvarchar(4000)
as
begin
declare @strlen int,@re nvarchar(4000)
declare @t table(chr nchar(1) collate Chinese_PRC_CI_AS,letter nchar(1))
insert into @t(chr,letter)
select '吖 ', 'A ' union all select '八 ', 'B ' union all
select '嚓 ', 'C ' union all select '咑 ', 'D ' union all
select '妸 ', 'E ' union all select '发 ', 'F ' union all
select '旮 ', 'G ' union all select '铪 ', 'H ' union all
select '丌 ', 'J ' union all select '咔 ', 'K ' union all
select '垃 ', 'L ' union all select '嘸 ', 'M ' union all
select '拏 ', 'N ' union all select '噢 ', 'O ' union all
select '妑 ', 'P ' union all select '七 ', 'Q ' union all
select '呥 ', 'R ' union all select '仨 ', 'S ' union all
select '他 ', 'T ' union all select '屲 ', 'W ' union all
select '夕 ', 'X ' union all select '丫 ', 'Y ' union all
select '帀 ', 'Z '
select @strlen=len(@str),@re= ' '
while @strlen> 0
begin
select top 1 @re=letter+@re,@strlen=@strlen-1
from @t a where chr <=substring(@str,@strlen,1)
order by chr desc
if @@rowcount=0
select @re=substring(@str,@strlen,1)+@re,@strlen=@strlen-1
end
return(@re)
end
函数2:
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
(
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函数
- 获取字符串的每个中文字符拼音首字母的ASP函数
- 获取汉字拼音首字母的SQL函数
- php获取中文字符拼音首字母和城市的排序
- 获取中文首字母mysql函数
- 得到中文字符的首字母
- php获取中文字符拼音首字母
- php获取中文字符拼音首字母
- 获取中文字符串拼音首字母串的函数
- 【代码】php 中文字符串首字母函数的获取
- 获取中文首字母的方法
- 获取中文字符串的首字母
- 获取中文汉字的首字母
- php 获取中文拼音首字母函数
- java 中文字符 获取首字母(一级二级字符)
- sql函数 获取汉字词组首字母
- 在.Net下获取中文字符拼音的首字母(一般排序时用到)
- 常见的MIME类型汇总(逐步收集)
- 就“CSDN高手”发一下议论。
- IT管理人才必须具备的十大能力
- pojo类的属性与数据库表字段名一样时,java通过反射拼凑出相应的sql.
- strtok
- 网上关于获取中文字符首字母的SQL函数
- JFrreChart createBubbleChart方法中Bubble大小的调节
- JS刷新父页面
- oop精解
- SQL Server 2000 中使用正则表达式
- 求助IIS401.2問題
- eclispe环境配置
- java环境配置
- 开始搞博客啦~~~