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 @ ...
随机推荐
- build.fxbuild打不开 Failed to create the part's controls
Failed to create the part's controls 以文本形式打开之后,发现编码的地方不是常用编码 将之修改为GBK 然后就可以正常打开了 最后把eclipse中的编码统一设置为 ...
- VS2010+Qt+OpenCv(显示图像)
Qt在界面显示窗口中起着越来越重要的作用,从而了解了下如何在Qt中显示一副图像. 该小程序主要注意一下几点: 1.工程属性中设置OpenCV的环境(包含目录和库目录,以及附加依赖项),设置Qt的环境( ...
- DBUnit的一些注意事项
DatabaseOperation.TRUNCATE_TABLE.execute(con, ds);等对数据库的操作放在每个@Test方法中做而不是在@Before里做,可增加灵活性
- Scrapy爬虫导图(持续完善中)
Scrapy是一个为了爬取网站数据,提取结构性数据而编写的应用框架. 可以应用在包括数据挖掘,信息处理或存储历史数据等一系列的程序中.
- Guava----Function
1. Function接口,提供两个方法: apply方法: 可以自定义自己想实现的功能 @Nullable T apply(@Nullable F input); 1. 实例: import com ...
- Android 布局中 如何使控件居中
首先要分两种不同情况,在两种不同的布局方式下:LinearLayout 和RelativeLayout 1. LinearLayout a). android:layout_gravity=" ...
- c#文本框限制输入内容
//限制输入不能为中文和全角 private void zhbh_KeyPress(object sender, KeyPressEventArgs e) { ...
- Python从零开始(1)新手常问
如何清除屏幕 如果是在Windows命令行中,输入 import os os.system('cls') 在IDEL中没有找到完美的清除屏幕的方法 网上提到用新建窗口的方法 如何退出Python提示符 ...
- [教训] windows 电脑的垃圾文件清理...
坑你没商量! 这个名叫 “清除系统垃圾.bat“ 的文件在网上传播很广,但是,却出现了错误的版本,如果按照它逐条执行,将导致系统文件夹被一锅端,只能再重装的悲剧! 举个栗子: 错误版本:http:// ...
- IOS跳转到设置特定项
App如何跳转到系统Settings 标签: IOS开发App转到Settings 2015-12-04 15:56 550人阅读 评论(1) 收藏 举报 分类: IOS开发(21) 版权声明:本 ...