zoukankan      html  css  js  c++  java
  • 创建取汉字首字母函数

    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 

  • 相关阅读:
    在线客服系统前端多国语言实现方案和代码
    索引下推,这个点你肯定不知道!
    拿捏!隔离级别、幻读、Gap Lock、Next-Key Lock
    现在已经卷到需要问三色标记了吗?
    听说你对explain 很懂?
    面试官:你说说一条更新SQL的执行过程?
    面试官:你说说一条查询SQL的执行过程
    别再纠结线程池大小线程数量了,没有固定公式的
    记一次慢SQL优化
    缓存热点,缓存穿透,终极解决方案看过来
  • 原文地址:https://www.cnblogs.com/zhycyq/p/3867232.html
Copyright © 2011-2022 走看看