sql获取汉字的拼音首字母
if exists (select * from sysobjects where id = object_id(N'[fn_ChineseToSpell]') and xtype in (N'FN', N'IF', N'TF')) www.2cto.com
drop function [fn_ChineseToSpell]
GO
/*创建取拼音首字母函数*/
create function [dbo].[fn_ChineseToSpell](@strChinese varchar(500)='')
returns varchar(500)
as
begin /*函数实现开始*/
declare @strLen int,@return varchar(500),@i int
declare @n int,@c char(1),@chn nchar(1)
select @strLen=len(@strChinese),@return='',@i=0
while @i<@strLen
begin /*while循环开始*/
select @i=@i+1,@n=63,@chn=substring(@strChinese,@i,1)
if @chn>'z'/*原理:“字符串排序以及ASCII码表”*/
select @n = @n +1,@c =case chn when @chn then char(@n) else @c end from(select top 27 * from (select chn = '吖' union all select '八' union all select '嚓' union all select '咑' union all select '妸' union all select '发' union all select '旮' union all select '铪' union all select '丌' /*because have no 'i'*/ union all select '丌' union all select '咔' union all select '垃' union all select '嘸' union all select '拏' union all select '噢' union all select '妑' union all select '七' union all select '呥' union all select '仨' union all select '他' union all select '屲' /*no 'u'*/ union all select '屲' /*no 'v'*/ union all select '屲' union all select '夕' union all select '丫' union all select '帀' union all select @chn) as a order by chn COLLATE Chinese_PRC_CI_AS ) as b
else
set @c=@chn
set @return=@return+@c
end /*while循环结束*/
return(@return)
end /*函数实现结束*/
使用方式:
select dbo.[fn_ChineseToSpell]('魏保光')
sql获取汉字的拼音首字母的更多相关文章
- sql获取汉字的拼音首字母的函数
ql获取汉字的拼音首字母 if exists (select * from sysobjects where id = object_id(N'[fn_ChineseToSpell]') and ...
- (转载)delphi中获取汉字的拼音首字母
delphi中获取汉字的拼音首字母1.py: array[216..247] of string = ({216}'CJWGNSPGCGNESYPB' + 'TYYZDXYKYGTDJNMJ' + ' ...
- C# 获取汉字的拼音首字母和全拼(含源码)
C# 获取汉字的拼音首字母 一种是把所有中文字符集合起来组成一个对照表:另一种是依照汉字在Unicode编码表中的排序来确定拼音的首字母.碰到多音字时就以常用的为准(第一种方法中可以自行更改,方法为手 ...
- 获取汉字的拼音首字母--pinyin
var pinyin = (function (){ var Pinyin = function (ops){ this.initialize(ops); }, options = { checkPo ...
- C#&Sql获取中文字符拼音首字母的方法
C#获取字符拼音首字母,可以存储在数据库中以备将来按字母搜索的需求. public static string GetAc(string s) { try { string temp = Servic ...
- C# 获取汉字的拼音首字母
/// <summary> /// 在指定的字符串列表CnStr中检索符合拼音索引字符串 /// </summary> /// <param name="CnS ...
- SqlServer 笔记二 获取汉字的拼音首字母
一.该函数传入字符串,返回数据为:如果为汉字字符,返回该字符的首字母,如果为非汉字字符,则返回本身. 二.用到的知识点:汉字对应的UNICODE值,汉字的排序规则. 三.数据库函数: )) ) AS ...
- sql语句 汉字转拼音首字母
(1)------------------------------------------------------------------------------------------------- ...
- SqlServer 获取汉字的拼音首字母
一.该函数传入字符串,返回数据为:如果为汉字字符,返回该字符的首字母,如果为非汉字字符,则返回本身.二.用到的知识点:汉字对应的UNICODE值,汉字的排序规则.三.数据库函数: CREATE FUN ...
随机推荐
- 关于nginx的1W并发的优化
我们来看一下图,下面的这张图清晰的表明了nginx优化的一些方法: nginx要响应请求的话,必须要: 1.要建立socket连接 2.是要读本地的文件 所以这就是我们的一个优化的方向: 所以参考照上 ...
- jQuery 求页面加载等待特效
这个案例是最近写一些前端展示的案例出现的一个问题,特此记录,使用ajax的一些方法和使用的技巧: $.ajax({ url:"", type:"post", d ...
- JQuery笔记汇总
jQuery相关资料 官网: jQuery官网 在线API: jQuery在线API W3School:W3School-jQuery教程(中文版哦) 下载jQuery:jQuery各版本下载 jQu ...
- apche 虚拟主机设置
<要求>:两个不同的域名 www.got7.com 和www.wgayi.com 指向同一个IP地址当在浏览器中输入不同的域名时.对应不同的网站根目录 备注:域名got7,wgayi,纯属 ...
- SQL server 2005中的锁(1)
在之前的一片随笔中,简单的说了一下SQL Server中的隔离级别.而SQL Server的隔离级别是通过锁的机制来实现的.现在深入一下,谈谈SQL Server中的锁. 开始之前,先要定义一下前提: ...
- VB.NET TextBox 只允许输入1-100之间的整数 简洁篇
Dim Str As String = "" Private Sub txtRecond_KeyUp(sender As System.Object, e As System.Wi ...
- 第8章 BOM
8.1 window对象 window有双重的角色,既可以通过JavaScript访问浏览器窗口的接口,又是ECMAScript规定的Global对象. 全局作用域中声明的变量.函数都会变成windo ...
- Android(Intent 学习)
Intent 是一个消息传递对象,Intent可以通过多种方式促进组件之间的通信,基本的三种用例: 启动Acitivity: Activity表示应用中的一个屏幕,通过将Intent传递给startA ...
- 【Python全栈笔记】01 [模块二] 14-15 Oct 运算符和字符串 4-1
编码的问题 中文版 Windows 终端是默认GBK编码格式,python2默认为ASCII编码,虽然我们注释了需要用UTF-8,但是通过命令行运行的文件如果print中文内容还是会出现乱码. Uni ...
- Redis学习笔记-初级
1.Redis简介 Redis是一个高效缓存内存数据库,开源.免费.key-value格式 相比于其他key-value格式的缓存产品,特点/优势在于: 支持持久化,可以将内存中的数据保存在磁盘中,重 ...