SqlServer 汉字转换拼音首字母函数
CREATE function [dbo].[Func_GetPY](@str nvarchar(4000))
returns nvarchar(4000)
as
begin
set @str=RTRIM(@str)
declare @word nchar(1),@PY nvarchar(4000)
set @PY=''
while len(@str)>0
begin
--处理常用多音字
if len(@str)>=2
begin
if left(@str,2)='重庆'
begin
set @PY=@PY+'CQ'
if LEN(@str)>2
set @str=right(@str,len(@str)-2)
else
set @str=''
end
if left(@str,2)='西藏'
begin
set @PY=@PY+'XZ'
if LEN(@str)>2
set @str=right(@str,len(@str)-2)
else
set @str=''
end
if left(@str,2)='藏族'
begin
set @PY=@PY+'ZZ'
if LEN(@str)>2
set @str=right(@str,len(@str)-2)
else
set @str=''
end
end
--汉字返回拼音首字母
if 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
end
return @PY
end
GO
SqlServer 汉字转换拼音首字母函数的更多相关文章
- Excel汉字转换拼音首字母缩写的函数
打开Excel->工具->宏->Viaual Basic编辑器在弹出来的窗口中对着VBAproject点右键->插入->模块下面会出现一个名为"模块1" ...
- sql获取汉字的拼音首字母的函数
ql获取汉字的拼音首字母 if exists (select * from sysobjects where id = object_id(N'[fn_ChineseToSpell]') and ...
- js汉字转拼音首字母
js汉字转拼音首字母 2018-04-09 阅读 1018 收藏 1 原链:segmentfault.com 分享到: 前端必备图书<JavaScript设计模式与开发实践> > ...
- (转载)delphi中获取汉字的拼音首字母
delphi中获取汉字的拼音首字母1.py: array[216..247] of string = ({216}'CJWGNSPGCGNESYPB' + 'TYYZDXYKYGTDJNMJ' + ' ...
- 汉字转拼音首字母的java实现
工作中经常会遇到的一些排序问题,比如 按汉字的拼音首字母排序,比如人名排序等,就要用到下面的方法了,思路: 1. 获得汉字 2. 将汉字转换成首字母,并记录下(必要时保存到数据库) 3. 按首字母进行 ...
- C#获取包括一二级汉字的拼音 首字母
C#获取包括一二级汉字的拼音 首字母 声母 汉字拼音转换 using System; using System.Collections.Generic; using System.Linq; usin ...
- 获取汉字的拼音首字母--pinyin
var pinyin = (function (){ var Pinyin = function (ops){ this.initialize(ops); }, options = { checkPo ...
- sql获取汉字的拼音首字母
if exists (select * from sysobjects where id = object_id(N'[fn_ChineseToSpell]') and xtype in (N'FN' ...
- 简单测试--C#实现中文汉字转拼音首字母
第一种: 这个是自己写的比较简单的实现方法,要做汉字转拼音首字母,首先应该有一个存储首字母的数组,然后将要转拼音码的汉字与每个首字母开头的第一个汉字即“最小”的汉字作比较,这里的最小指的是按拼音规则比 ...
随机推荐
- 克隆git仓库中的一个分支
克隆git仓库中的某一个分支,可用如下命令: git clone -b <branch_name> <repo> 如:git clone -b hdcp_ree_tee_dev ...
- NGINX----源码阅读---config配置脚本
config文件为nginx的配置入口文件. 1. #!/bin/sh # Copyright (C) Igor Sysoev # Copyright (C) Nginx, Inc. LC_ALL=C ...
- CSS3之3D效果中的transform运用
css3中添加了很多新的标签 属性 描述 css transform 向元素应用 2D 或 3D 转换. 3 transform-origin 允许你改变被转换元素的位置. 3 transform-s ...
- Android如何查看应用签名信息
转自http://www.trinea.cn/android/android-view-signatures/comment-page-1/ 介绍Android如何查看自己的应用签名及三方APK或系统 ...
- OSI参考模型初识
纪念我曾今热爱的数通(^o^). 1.osi参考模型 2.数据的封装和解封装 3.主机和主机间通信
- Dojo的UI框架bootstrap for dojo和Dojo-Bootstrap简介
最近在学习Dojo,但样式问题真是头疼呀,虽然清新的淡蓝色很是减缓眼睛的疲劳,但这个扁平化简约风盛行的年代,光是清新的拟物已经满足不了群众的需求了,所以就在这样的需求下,我知道了bootstrap f ...
- 洛谷-求同构数的个数-NOIP2013提高组复赛
题目描述 Description 所谓同构数是指这样的数,即它出现在它的平方数的右端.例如,5的平方是25 (即5×5=25),5是25右端的数,那么5就是同构数.又如,25的平方是625(即25×2 ...
- java变量和数据类型总结
- 快乐编程学ruby
人们常说:不忘初心,方得始终.所以,code除了完成工作任务,在最初还应该是富于乐趣的,正所谓,宅男配女仆,我们来了解了解我们的ruby 萌妹子吧:-). ...
- drupal 连表查询+分页
$query = db_select('Table','t'); $query->join('Table_A','a','on条件); $query->join('Table_B','b' ...