• sql中写标量函数生成大写拼音首字母


    USE [StockManageSystemV2]
    GO
    /****** Object:  UserDefinedFunction [dbo].[PinYin]    Script Date: 2016-08-07 11:19:20 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    
    ALTER FUNCTION [dbo].[PinYin] ( @STR NVARCHAR(4000) )
    RETURNS NVARCHAR(4000)
    AS
        BEGIN
            DECLARE    @INTLEN INT;
            DECLARE    @STRRET NVARCHAR(4000);
            DECLARE    @TEMP NVARCHAR(100);
            SET @INTLEN = LEN(@STR);
            SET @STRRET = '';
            WHILE @INTLEN > 0
                BEGIN
                    SET @TEMP = '';
                    SELECT    @TEMP = CASE WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'Z'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'Y'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'X'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'W'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'T'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'S'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'R'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'Q'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'P'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'O'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'N'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'M'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'L'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'K'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'J'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'H'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'G'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'F'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'E'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'D'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'C'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'B'
                                         WHEN SUBSTRING(@STR, @INTLEN, 1) >= '' THEN 'A'
                                         ELSE RTRIM(LTRIM(SUBSTRING(@STR, @INTLEN, 1)))
                                    END;
            --对于汉字特殊字符,不生成拼音码
                    IF ( ASCII(@TEMP) > 127 )
                        SET @TEMP = '';
            --对于英文中小括号,不生成拼音码
                    IF @TEMP = '('
                        OR @TEMP = ')'
                        SET @TEMP = '';
                    SELECT    @STRRET = @TEMP + @STRRET;
                    SET @INTLEN = @INTLEN - 1;
                END;
            RETURN @STRRET;
        END;
  • 相关阅读:
    jQuery的end() 方法
    jQuery.extend 函数使用详解
    AutoMapper完成Dto与Model的转换
    IoC实践--用Unity实现MVC5.0的IoC控制反转方法
    IoC实践--用Autofac实现MVC5.0的IoC控制反转方法
    Unity依赖注入使用详解
    React+BootStrap+ASP.NET MVC实现自适应和组件的复用
    oracle基础开发工具及常用命令
    Cisco配置发送日志到日志服务器
    Redis讲解
  • 原文地址:https://www.cnblogs.com/wenjieyatou/p/5745821.html
Copyright © 2020-2023  润新知