博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
创建取汉字首字母函数
阅读量:5173 次
发布时间:2019-06-13

本文共 1699 字,大约阅读时间需要 5 分钟。

create function [dbo].[f_getpy_V4] 

    @col varchar(1000) 
returns varchar(1000) 
    begin 
        declare @cyc int,@len int,@sql varchar(1000),@char varbinary(20) 
        select @cyc = 1,@len = len(@col),@sql = '' 
        while @cyc <= @len  
            begin   
                select @char = cast(substring(@col, @cyc, 1) as varbinary) 
                if @char>=0XB0A1 and @char<=0XB0C4      set @sql=@sql+'A' 
                else if @char>=0XB0C5 and @char<=0XB2C0 set @sql=@sql+'B' 
                else if @char>=0XB2C1 and @char<=0XB4ED set @sql=@sql+'C' 
                else if @char>=0XB4EE and @char<=0XB6E9 set @sql=@sql+'D' 
                else if @char>=0XB6EA and @char<=0XB7A1 set @sql=@sql+'E' 
                else if @char>=0XB7A2 and @char<=0XB8C0 set @sql=@sql+'F' 
                else if @char>=0XB8C1 and @char<=0XB9FD set @sql=@sql+'G' 
                else if @char>=0XB9FE and @char<=0XBBF6 set @sql=@sql+'H' 
                else if @char>=0XBBF7 and @char<=0XBFA5 set @sql=@sql+'J' 
                else if @char>=0XBFA6 and @char<=0XC0AB set @sql=@sql+'K' 
                else if @char>=0XC0AC and @char<=0XC2E7 set @sql=@sql+'L' 
                else if @char>=0XC2E8 and @char<=0XC4C2 set @sql=@sql+'M' 
                else if @char>=0XC4C3 and @char<=0XC5B5 set @sql=@sql+'N' 
                else if @char>=0XC5B6 and @char<=0XC5BD set @sql=@sql+'O' 
                else if @char>=0XC5BE and @char<=0XC6D9 set @sql=@sql+'P' 
                else if @char>=0XC6DA and @char<=0XC8BA set @sql=@sql+'Q' 
                else if @char>=0XC8BB and @char<=0XC8F5 set @sql=@sql+'R' 
                else if @char>=0XC8F6 and @char<=0XCBF9 set @sql=@sql+'S' 
                else if @char>=0XCBFA and @char<=0XCDD9 set @sql=@sql+'T' 
                else if @char>=0XCDDA and @char<=0XCEF3 set @sql=@sql+'W' 
                else if @char>=0XCEF4 and @char<=0XD1B8 set @sql=@sql+'X' 
                else if @char>=0XD1B9 and @char<=0XD4D0 set @sql=@sql+'Y' 
                else if @char>=0XD4D1 and @char<=0XD7F9 set @sql=@sql+'Z' 
                set @cyc = @cyc + 1  
            end 
        return @sql 
    end 
go 

转载于:https://www.cnblogs.com/zhycyq/p/3867232.html

你可能感兴趣的文章
个人作业week7——前端开发感想总结
查看>>
[转]js和jquery获取窗体高度
查看>>
Eureka的自我保护模式
查看>>
Java通过BCrypt加密
查看>>
学习总结 java基础
查看>>
SQL(1)—增删改查
查看>>
Spring+Quartz 整合二:调度管理与定时任务分离
查看>>
ubuntu下编译ffmpeg并用eclipse调试
查看>>
oracle分页查询
查看>>
微信自定义分享
查看>>
CSS基础part1
查看>>
魔兽世界服务器Trinitycore分析二:auth server的main函数
查看>>
MFC防止进程重复建立
查看>>
3. Node.js REPL(交互式解释器)
查看>>
webview滑动事件 与内部html左右滑动事件冲突问题的解决办法
查看>>
傅里叶变换学习总结
查看>>
java面试题汇总(1)
查看>>
VC Dimension -衡量模型与样本的复杂度
查看>>
android 中 ViewPager 的平常用法 ViewPager+ Views
查看>>
POJ 2449 Remmarguts' Date (SPFA + A星算法) - from lanshui_Yang
查看>>