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. [bzoj4765]普通计算姬——分块

    Brief Description 给定一棵n个节点的带权树,节点编号为1到n,以root为根,设sum[p]表示以点p为根的这棵子树中所有节点的权 值和.支持下列两种操作: 1 给定两个整数u,v, ...

  2. POJ2245 Lotto

    Lotto Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6634   Accepted: 4201 Description ...

  3. git放弃本地commit,未push

    如果不小心commit了一个不应该commit的修改,但是还没有push,想撤销那个commit. 步骤: a) git log:获取commit id: b) git reset --hard co ...

  4. pressmuSpiderr

    #!/usr/bin/env python # encoding: utf-8 import requests from random import choice from lxml import h ...

  5. 关于easyui checkbox 的一些操作处理

    1.easyui在每一行加checkbox { field: 'id', title: '编号', checkbox: true } 2.easyui分页时记住前面已选的checkbox 设置easy ...

  6. Java 5大内存区域和对象的创建过程

    1.Java运行时数据区 方法区,堆线程共享.虚拟机栈,本地方法栈和程序计数器线程私有. 2.程序计数器(PC计数器) 占用较小的一块内存空间,当执行Java方法时记录正在执行的虚拟机字节码指令地址, ...

  7. 使用bottle进行web开发(5):Generating Content

    在纯粹的 WSGI中,你的应用能返回的数据类型是十分有限的,你必须返回可迭代的字符串,你能返回字符串是因为字符串是可以迭代的,但是这导致服务器将你的内容按一字符一字符的传送,这个时候,Unicode ...

  8. maven基本知识

    maven的文件夹: projectName src -main -java -package -test -java     -package  -resource maven的命令: mvn - ...

  9. ubuntu下中文输入法安装

    个人认为ubantu下fcitx比sogo好用 安装fcitx首先到ubantu软件中心下载fcitx两个软件,一个是配置软件,一个是输入法软件 到system setting中language su ...

  10. <div>之定位

    在使用盒子模型的过程中,如何放置各种类型的“盒子”,就存在定位.浮动等问题.下面就日常运用过程中出现过的情况总结如下(陆续加入中....) 一.图片直接做<div>的背景 在<div ...