ql获取汉字的拼音首字母
 
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获取汉字的拼音首字母的函数的更多相关文章

  1. sql获取汉字的拼音首字母

    if exists (select * from sysobjects where id = object_id(N'[fn_ChineseToSpell]') and xtype in (N'FN' ...

  2. (转载)delphi中获取汉字的拼音首字母

    delphi中获取汉字的拼音首字母1.py: array[216..247] of string = ({216}'CJWGNSPGCGNESYPB' + 'TYYZDXYKYGTDJNMJ' + ' ...

  3. C# 获取汉字的拼音首字母和全拼(含源码)

    C# 获取汉字的拼音首字母 一种是把所有中文字符集合起来组成一个对照表:另一种是依照汉字在Unicode编码表中的排序来确定拼音的首字母.碰到多音字时就以常用的为准(第一种方法中可以自行更改,方法为手 ...

  4. 获取汉字的拼音首字母--pinyin

    var pinyin = (function (){ var Pinyin = function (ops){ this.initialize(ops); }, options = { checkPo ...

  5. C#&Sql获取中文字符拼音首字母的方法

    C#获取字符拼音首字母,可以存储在数据库中以备将来按字母搜索的需求. public static string GetAc(string s) { try { string temp = Servic ...

  6. C# 获取汉字的拼音首字母

    /// <summary> /// 在指定的字符串列表CnStr中检索符合拼音索引字符串 /// </summary> /// <param name="CnS ...

  7. SqlServer 笔记二 获取汉字的拼音首字母

    一.该函数传入字符串,返回数据为:如果为汉字字符,返回该字符的首字母,如果为非汉字字符,则返回本身. 二.用到的知识点:汉字对应的UNICODE值,汉字的排序规则. 三.数据库函数: )) ) AS ...

  8. sql语句 汉字转拼音首字母

    (1)------------------------------------------------------------------------------------------------- ...

  9. SqlServer 获取汉字的拼音首字母

    一.该函数传入字符串,返回数据为:如果为汉字字符,返回该字符的首字母,如果为非汉字字符,则返回本身.二.用到的知识点:汉字对应的UNICODE值,汉字的排序规则.三.数据库函数: CREATE FUN ...

随机推荐

  1. POJ 1002 487-3279 (map )

    title: 487-3279 map POJ1002 tags: [map] 题目链接 Description Businesses like to have memorable telephone ...

  2. R的农场

    R的农场 题目描述 最近,R 终于获得了一片他梦寐以求的农场,但如此大的一片农场,想要做好防卫工作可不是一件容易的事.所以 R 购买了 N 个守卫,分别让他们站在一定的位置上(守卫不可移动,同一位置上 ...

  3. UVa 12265 贩卖土地 单调栈

    题意 输入一个\(n\times m\)的矩阵,每个格子可能是空地,也可能是沼泽.对于每个空地格子,求出以它为右下角的空矩形的最大周长,然后统计每个周长出现了多少次. 思路 对于 每一行 每两个沼泽之 ...

  4. Golang在视频直播平台的高性能实践(含PPT下载)

    熊猫 TV 是一家视频直播平台,先介绍下我们系统运行的环境,下面这 6 大服务只是我们几十个服务中的一部分,由于并发量与重要性比较高,所以成为 golang 小试牛刀的首批高性能高并发服务. 把大服务 ...

  5. http://www.himigame.com/mac-cocoa-application/893.html

    [Cocoa(mac) Application 开发系列之一]创建第一个application—计算器 终于HTTP与Socket服务器以及cocos2dx之间的通信各种框架成功完成后,现在抽时间学习 ...

  6. Sikuli 安装使用之初体验(为Sikuli X指定jre路径)

    Sikuli 是一种新颖的图形脚本语言,在实际的自动化测试中如果仅仅依靠selenium 还是远远不够的,selenium自动化本身是存在着诸多缺陷的,基于浏览器之外的控件 (windows 控件 等 ...

  7. hadoop3.1 分布式集群部署

    1.环境准备 Centos7.5系统 hadoop版本3.1 1.1资源分配 主机名 地址 角色 node01 10.10.0.11 namenode node02 10.10.0.12 second ...

  8. python-函数(装饰器)

    装饰器 装饰器的主要功能: 在不改变函数调用方式的基础上在函数的前.后添加功能. 装饰器的固定格式: #装饰器的本质 :闭包函数 #功能:就是在不改变原函数调用方式的情况下,在这个函数前后加上扩展功能 ...

  9. nginx部署vue工程和反向代理nodejs工程

    前端是vue,后端是nodejs 前端打包成dist目录,后端接口是localhost:4000/api server { listen 80; #listen [::]:80; server_nam ...

  10. 举例说明如何使用【聚合数据】的API接口

    0 注册[聚合数据]的账号 登陆www.juhe.cn,如图,如果没有账号,注册一个(手机号或者邮箱注册),如果有直接登陆即可. 1 搜索所需的API接口 找到聚合数据主页,在搜索框输入你想搜索的AP ...