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. float/文档流

    float : left | right | none | inherit; 文档流是文档中可显示对象在排列时所占用的位置. 浮动的定义: 使元素脱离文档流,按照指定方向发生移动,遇到父级边界或者相邻 ...

  2. 全局axios默认值 和 自定义实例默认值

    首先说了一下情况, 登录后成功返回token 然后在带着token去继续下面的请求, 奇怪的是都是当前页面起作用,刷新和跳转之后就token 就消失了. 查了 axios文档发现 被自己坑了 我设置了 ...

  3. python基础===两个list合并成一个dict的方法

    def Run(): list2 = [, , , , ]; list3 = ["a", "b", "c", "d",& ...

  4. Linux 的源码安装工具 CheckInstall

    Linux 的源码安装工具 CheckInstall Checkinstall 是一个能从 tar.gz 类的 https://www.ibm.com/developerworks/cn/linux/ ...

  5. PL/SQL 03 流程控制

    --IF语法IF condition THEN  statements;[ELSIF condition THEN  statements;][ELSE  statements;]END IF; -- ...

  6. Oracle 11g 安装环境配置脚本

    #!/bin/bash #Test in RHEL 5.5 for 11g c=`cat /etc/shadow | grep oracle | wc -l`if [ $c != 0 ]then  w ...

  7. Selenium2+python自动化28-table定位【转载】

    前言 在web页面中经常会遇到table表格,特别是后台操作页面比较常见.本篇详细讲解table表格如何定位. 一.认识table 1.首先看下table长什么样,如下图,这种网状表格的都是table ...

  8. js 集合

    [深入理解javascript原型和闭包系列 ] 历时半月完稿,求推荐 jQuery 学习笔记(未完待续) JavaScript作用域原理(三)——作用域根据函数划分

  9. jquerycheckbox事件

    https://stackoverflow.com/questions/7031226/jquery-checkbox-change-and-click-event $(document).ready ...

  10. eclipse断点调试基础

    进入debug模式: 1.设置断点 2.启动servers端的debug模式 3.运行程序,在后台遇到断点时,进入debug调试状态 ============================= 作用域 ...