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 @ ...
随机推荐
- Android开发之Git配置
Android开发之Git配置 1.首先git配置: 输入命令: git config --global user.name "xxx.xx" git config --globa ...
- samba完美安装
感觉是一个相当强大的东西. Samba是在Linux和UNIX系统上实现SMB协议的一个免费软件.它为局域网内的不同计算机之间提供文件及打印机等资源的共享服务.为客户机/服务器型协议,客户机通过该协议 ...
- Appium之python API
webdriver contexts(self) 说明:返回多个会话内容 使用:driver.contexts current_context(self) 说明:返回单个会话的内容 使用:driver ...
- ubuntu 跟xshell的问题
有2个分析: 1:是windos的防火墙没有关闭 2:是虚拟机没有安装sshd服务器 ubuntu在CLI界面下输入:dpkg -l |grep ssh 因为是我安装过的sshd server 要 ...
- Python常用内置函数总结
一.数学相关 1.绝对值:abs(-1)2.最大最小值:max([1,2,3]).min([1,2,3])3.序列长度:len('abc').len([1,2,3]).len((1,2,3))4.取模 ...
- Python’s SQLAlchemy vs Other ORMs[转发 6]SQLAlchemy
SQLAlchemy SQLAlchemy is an open source SQL toolkit and ORM for the Python programming language rele ...
- MVC5+EF6 入门完整教程四
上篇文章主要讲了如何配置EF, 我们回顾下主要过程: 创建Data Model à 创建Database Context à创建databaseInitializerà配置entityFramewor ...
- win7优化
- HashMap & HashTable的区别
HashMap & HashTable的区别主要有以下: 1.HashMap是线程不安全的,HashTable是线程安全的.由这点区别可以知道,不考虑线程安全的情况下使用HashMap的效率明 ...
- hdoj 1385Minimum Transport Cost
卧槽....最近刷的cf上有最短路,本来想拿这题复习一下.... 题意就是在输出最短路的情况下,经过每个节点会增加税收,另外要字典序输出,注意a到b和b到a的权值不同 然后就是处理字典序的问题,当松弛 ...