SQL获取汉字首字母
create function f_GetPy(@str nvarchar(4000))
returns nvarchar(4000)
as
begin
declare @strlen int,@re nvarchar(4000)
declare @t table(chr nchar(1) collate Chinese_PRC_CI_AS,letter nchar(1))
insert into @t(chr,letter)
select '吖','A' union all select '八','B' union all
select '嚓','C' union all select '咑','D' union all
select '妸','E' union all select '发','F' union all
select '旮','G' union all select '铪','H' union all
select '丌','J' union all select '咔','K' union all
select '垃','L' union all select '嘸','M' union all
select '拏','N' union all select '噢','O' union all
select '妑','P' union all select '七','Q' union all
select '呥','R' union all select '仨','S' union all
select '他','T' union all select '屲','W' union all
select '夕','X' union all select '丫','Y' union all
select '帀','Z'
select @strlen=len(@str),@re=''
while @strlen>0
begin
select top 1 @re=letter+@re,@strlen=@strlen-1
from @t a where chr<=substring(@str,@strlen,1)
order by chr desc
if @@rowcount=0
select @re=substring(@str,@strlen,1)+@re,@strlen=@strlen-1
end
return(@re)
end
go update BY_CustomerContacter Set Initials=upper(substring(dbo.f_GetPy(ContacterName), 1, 1))
update BY_SupplierContacter Set Initials=upper(substring(dbo.f_GetPy(ContacterName), 1, 1)) drop function dbo.f_GetPy select Initials,ContacterName,Id from BY_CustomerContacter order by Initials asc
select Initials,ContacterName,Id from BY_SupplierContacter order by Initials asc
SQL获取汉字首字母的更多相关文章
- JS获取汉字首字母
//获取 汉字首字母 function makePy(str) { if (typeof (str) != "string") throw new Error(-1, " ...
- ASP.NET获取汉字首字母
/// <summary> /// 获取汉字首字母(可包含多个汉字) /// </summary> /// <param name="strText" ...
- php获取汉字首字母
php获取汉字首字母,可以用于按字母对数据进行检索排序等. 分享下网上找的代码.亲测有效. function getFirstCharter($str){ if(empty($str)){return ...
- JS实现获取汉字首字母拼音、全拼音及混拼音的方法
本文实例讲述了JS实现获取汉字首字母拼音.全拼音及混拼音的方法.分享给大家供大家参考,具体如下: 这里需要用到一个js获取汉字拼音的插件,可点击此处本站下载. 运行效果如下: 完整示例代码: ? 1 ...
- .NET获取汉字首字母
/// <summary> /// 获取汉字首字母(可包含多个汉字) /// </summary> /// <param name="strText" ...
- python获取汉字首字母
获取汉字首字母 关注公众号"轻松学编程"了解更多. 应用场景之一:可用于获取名字首字母,在数据库中查询记录时,可以用它来排序输出. from pytz import unicode ...
- php获取汉字首字母的函数
本文介绍用php实现汉字转化为首字母的方法,主要功能是:功能明确,易于修改维护和扩展: 英文的字串:不变返回(包括数字):中文字符串:返回拼音首字符: 中英混合串: 返回拼音首字符和英文. 网上的方法 ...
- ms sql 获取字符串首字母
很久没有编写新文章,现在发布一篇自定义函数,针对于ms sql数据库中需要获取字符串首字母,对于需要的朋友希望对你有用,如果你有更好的方法也可以给我留言.函数如下: --获取字符串首字母 CREATE ...
- SQL函数-汉字首字母查询
汉字首字母查询处理用户定义函数 CREATE FUNCTION f_GetPY1(@str nvarchar(4000))RETURNS nvarchar(4000)ASBEGIN DECLARE @ ...
随机推荐
- git pull 然后 ahead of origin/master * commit 消失
本来显示 your branch is ahead origin/master * commit后来也许在master merge 这个分支后, 然后git pull, 就显示Your branch ...
- adb pull apk
adb shell pm list packages adb shell pm path com.tence01.mm find -name *.apk adb pull /data/app/com. ...
- nginx配合zabbix编译安装时web下一步跳转问题
很多时候编译安装的时候把zabbix的php包拷贝到web所在目录之后(本文为nginx所在html目录),网页打开http:/localhost/zabbix却进不去下图: 或者是点了下一步没反应, ...
- RedHat下apache\ftp\mysql 4.0 的安装方法
RedHat下安装这三个服务的方法大同小异 Apache服务: 找到Apache安装包: rpm -ivh httpd-2.0.40-21.i386.rpm 等待安装完成即可 检查安装结果: rpm ...
- MongoDB 备份(mongodump)与恢复(mongorestore)
MongoDB数据备份 在Mongodb中我们使用mongodump命令来备份MongoDB数据.该命令可以导出所有数据到指定目录中. mongodump命令可以通过参数指定导出的数据量级转存的服务器 ...
- 机器学习之决策树熵&信息增量求解算法实现
此文不对理论做相关阐述,仅涉及代码实现: 1.熵计算公式: P为正例,Q为反例 Entropy(S) = PLog2(P) - QLog2(Q); 2.信息增量计算: Gain(S,Sv) = E ...
- DPDK内存管理(1)
1 前言 DPDK将利用hugepage预留的物理内存统一的组织管理起来,然后以库的方式对外提供使用的接口.下图展示了DPDK中内存有关的模块的相互关系. rte_eal 是统一 ...
- java 文件按行读取
/*代码写的可能有点累赘里面的好多东西写的不太好 还望各位大佬能提点一二,不胜感激*/package com.zzp.fileopration;import java.io.*;/** * Creat ...
- tomcat重启脚本
#!/bin/bashPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/binexport JAVA_HOME=/opt/jd ...
- spark发行版笔记9
感谢DT大数据梦工厂支持提供技术支持,DT大数据梦工厂专注于Spark发行版定制. 本期概览: 1 Receiver生命全周期 首先,我们找到数据来源的入口,入口如下 Receiver的设计是极其巧妙 ...