抄一个汉字转汉语拼音缩写的存储过程

If Exists (Select name From sysobjects
Where name = 'HZToPY' And type = 'FN')
Drop Function HZToPY
GO

Create Function HZToPY(@HZ VarChar(50))
Returns VarChar(50)
As
Begin
 Declare @PY VarChar(50),@LenHZ int,@i int,@FristWord VarChar(2)
 Set @LenHZ = Len(@HZ)
 Set @i = 1
 Set @PY = ''
 While @i <= @LenHZ
 Begin
   Set @FristWord = SubString(@HZ,@i,1)
 
   If( @FristWord < '八' )
   Begin
     If (@FristWord >= '0' And @FristWord <= '9') Set @PY = @PY + @FristWord
     Else If (@FristWord >= 'A' And @FristWord <= 'Z') Set @PY = @PY + @FristWord
     Else Set @PY = @PY + ''    
   End
   Else If( @FristWord < '嚓' ) Set @PY = @PY + 'B'
   Else If( @FristWord < '咑' ) Set @PY = @PY + 'C'
   Else If( @FristWord < '妸' ) Set @PY = @PY + 'D'
   Else If( @FristWord < '发' ) Set @PY = @PY + 'E'
   Else If( @FristWord < '旮' ) Set @PY = @PY + 'F'
   Else If( @FristWord < '铪' ) Set @PY = @PY + 'G'
   Else If( @FristWord < '讥' ) Set @PY = @PY + 'H'
   Else If( @FristWord < '咔' ) Set @PY = @PY + 'J'
   Else If( @FristWord < '垃' ) Set @PY = @PY + 'K'
   Else If( @FristWord < '嘸' ) Set @PY = @PY + 'L'
   Else If( @FristWord < '拏' ) Set @PY = @PY + 'M'
   Else If( @FristWord < '噢' ) Set @PY = @PY + 'N'
   Else If( @FristWord < '妑' ) Set @PY = @PY + 'O'
   Else If( @FristWord < '七' ) Set @PY = @PY + 'P'
   Else If( @FristWord < '亽' ) Set @PY = @PY + 'Q'
   Else If( @FristWord < '仨' ) Set @PY = @PY + 'R'
   Else If( @FristWord < '他' ) Set @PY = @PY + 'S'
   Else If( @FristWord < '哇' ) Set @PY = @PY + 'T'
   Else If( @FristWord < '夕' ) Set @PY = @PY + 'W'
   Else If( @FristWord < '丫' ) Set @PY = @PY + 'X'
   Else If( @FristWord < '帀' ) Set @PY = @PY + 'Y'
   Else If( @FristWord < '咗' ) Set @PY = @PY + 'Z'
   Else Set @PY = @PY + ''

   Set @i = @i + 1
 End
 Return (@PY)
End

Go
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值