• sql拼音简写函数


    USE [HotelDB]
    GO

    /****** Object: UserDefinedFunction [dbo].[fn_GetPy] Script Date: 2016/1/4 13:29:13 ******/
    SET ANSI_NULLS ON
    GO

    SET QUOTED_IDENTIFIER ON
    GO


    ALTER function [dbo].[fn_GetPy](@str nvarchar(4000))
    returns nvarchar(4000)
     --用于加密
    --WITH ENCRYPTION
    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 lower(@strRet)
    end
    GO

  • 相关阅读:
    js设计模式 -- 拷贝模式
    超简单的SpringBoot整合mybatis
    使用JS调用手机本地摄像头或者相册图片识别二维码/条形码
    SpringBootsad整合EhCache做缓存处理
    调用微信的扫一扫功能详解说明---(java 排坑版)
    获取系统文件的创建日期
    在windows上获取文件创建时间
    简单计算器
    lambda-基于谓词筛选值序列
    IEnumerable<T>和IQueryable<T>区别
  • 原文地址:https://www.cnblogs.com/taomylife/p/5101828.html
Copyright © 2020-2023  润新知