转换拼音简码

执行:dbo.FB_GetChineseSpell(chzxm)

CREATE FUNCTION [dbo].[FB_GetChineseSpell]
(
@Str varchar(500)=''
)
RETURNS varchar(500)
as
begin
declare @strLen int
declare @index int
declare @VChControl char(2)
DECLARE @VChSpell VARCHAR(30)
declare @return varchar(500)
set @return=''
set @strlen=len(@str)
set @index=1
while @index<=@strlen
begin
select @VChControl=substring(@str,@index,1)
IF @VChControl>'啊' AND @VChControl<'芭'
SELECT @VChSpell='A'
ELSE IF @VChControl>='芭' AND @VChControl<'擦'
SELECT @VChSpell='B'
ELSE IF @VChControl>='擦' AND @VChControl<'搭'
SELECT @VChSpell='C'
ELSE IF @VChControl>='搭' AND @VChControl<'娥'
SELECT @VChSpell='D'
ELSE IF @VChControl>='娥' AND @VChControl<'发'
SELECT @VChSpell='E'
ELSE IF @VChControl>='发' AND @VChControl<='嘎'
SELECT @VChSpell='F'
ELSE IF @VChControl>'嘎' AND @VChControl<'哈'
SELECT @VChSpell='G'
ELSE IF @VChControl>='哈' AND @VChControl<'击'
SELECT @VChSpell='H'
ELSE IF @VChControl>='击' AND @VChControl<'喀'
SELECT @VChSpell='J'
ELSE IF @VChControl>='喀' AND @VChControl<'垃'
SELECT @VChSpell='K'
ELSE IF @VChControl>='垃' AND @VChControl<'妈'
SELECT @VChSpell='L'
ELSE IF @VChControl>='妈' AND @VChControl<'拿'
SELECT @VChSpell='M'
ELSE IF @VChControl>='拿' AND @VChControl<'哦'
SELECT @VChSpell='N'
ELSE IF @VChControl>='哦' AND @VChControl<'啪'
SELECT @VChSpell='O'
ELSE IF @VChControl>='啪' AND @VChControl<'期'
SELECT @VChSpell='P'
ELSE IF @VChControl>='期' AND @VChControl<'然'
SELECT @VChSpell='Q'
ELSE IF @VChControl>='然' AND @VChControl<'撒'
SELECT @VChSpell='R'
ELSE IF @VChControl>='撒' AND @VChControl<'塌'
SELECT @VChSpell='S'
ELSE IF @VChControl>='塌' AND @VChControl<'挖'
SELECT @VChSpell='T'
ELSE IF @VChControl>='挖' AND @VChControl<'昔'
SELECT @VChSpell='W'
ELSE IF @VChControl>='昔' AND @VChControl<'压'
SELECT @VChSpell='X'
ELSE IF @VChControl>='压' AND @VChControl<'匝'
SELECT @VChSpell='Y'
ELSE IF @VChControl>='匝' AND @VChControl<='座'
SELECT @VChSpell='Z'
ELSE
SELECT @VChSpell=@VChControl

SELECT @return=@return + RTRIM(UPPER(@VChSpell))
set @index=@index+1
end
return(@return)
end

posted @ 2016-05-20 08:48  傲三  阅读(202)  评论(0编辑  收藏  举报