您当前的位置: 首页 >  sql

[MSSQL]取汉字首字母的两个函数

发布时间:2012-02-14 08:30:35 ,浏览量:0

go
--创建取汉字首字母函数(第一版)
create function [dbo].[f_getpy_V1] (@str nvarchar(4000)) 
returns nvarchar(4000) 
as
begin 
declare @word nchar(1),@py nvarchar(4000) 
set @py='' 
while len(@str)>0 
begin 
set @word=left(@str,1) 
set @py = @py+ (case when unicode(@word) between 19968 and 19968+20901 
then ( 
select top 1 py 
from 
( 
select 'a' as py, N'驁' as word 
union all select 'B',N'簿' 
union all select 'C',N'錯' 
union all select 'D',N'鵽' 
union all select 'E',N'樲' 
union all select 'F',N'鰒' 
union all select 'G',N'腂' 
union all select 'H',N'夻' 
union all select 'J',N'攈' 
union all select 'K',N'穒' 
union all select 'L',N'鱳' 
union all select 'M',N'旀' 
union all select 'N&
关注
打赏
1688896170
查看更多评论

暂无认证

  • 0浏览

    0关注

    106347博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0710s