zoukankan      html  css  js  c++  java
  • SQL函数取汉字拼音首字母

     1 CREATE function f_GetFirstPy(@str varchar(50)='')
     2     returns char(1)
     3 as
     4 begin
     5     declare @n int, @c char(1), @chn nchar(1)
     6     select @n=63, @chn=substring(@str,1,1)
     7     if @chn > 'z'
     8         if( @chn < '' ) set @c = 'A'
     9         else if ( @chn < '' ) set @c = 'B'
    10         else if ( @chn < '' ) set @c = 'C'
    11         else if ( @chn < '' ) set @c = 'D'
    12         else if ( @chn < '' ) set @c = 'E'
    13         else if ( @chn < '' ) set @c = 'F'
    14         else if ( @chn < '' ) set @c = 'G'
    15         else if ( @chn < '' ) set @c = 'H'
    16         else if ( @chn < '' ) set @c = 'I'
    17         else if ( @chn < '' ) set @c = 'J'
    18         else if ( @chn < '' ) set @c = 'K'
    19         else if ( @chn < '' ) set @c = 'L'
    20         else if ( @chn < '' ) set @c = 'M'
    21         else if ( @chn < '' ) set @c = 'N'
    22         else if ( @chn < '' ) set @c = 'O'
    23         else if ( @chn < '' ) set @c = 'P'
    24         else if ( @chn < '' ) set @c = 'Q'
    25         else if ( @chn < '' ) set @c = 'R'
    26         else if ( @chn < '' ) set @c = 'S'
    27         else if ( @chn < '' ) set @c = 'T'
    28         else if ( @chn < '' ) set @c = 'U'
    29         else if ( @chn < '' ) set @c = 'V'
    30         else if ( @chn < '' ) set @c = 'W'
    31         else if ( @chn < '' ) set @c = 'X'
    32         else if ( @chn < '' ) set @c = 'Y'
    33         else set @c = 'Z'
    34     else if @chn <= 'z' and @chn >= 'a'
    35         set @c = upper(@chn)
    36     else if @chn <= 'Z' and @chn >= 'A'
    37         set @c = @chn
    38     else
    39         set @c = ''
    40     return (@c)
    41 end
  • 相关阅读:
    dockerfile构建的镜像中文乱码
    xshell+xmanager6破解
    mysql数据库本地登录无法查看到数据库
    Tomcat日志中文乱码问题解决
    Tomcat 启动很慢
    Supervisor-安装
    supervisor-monitor进程集中管理部署
    CeSi 进程集中管理部署
    [IOT]
    [SourceTree]
  • 原文地址:https://www.cnblogs.com/xuejietong/p/8902166.html
Copyright © 2011-2022 走看看