獲取拼音碼的儲存過程,首拼

2021-09-26 02:25:31 字數 1481 閱讀 8719

create function f_getpy(@str nvarchar(4000))

returns nvarchar(4000)

asbegin

declare @py table(

ch char(1),

hz1 nchar(1) collate chinese_prc_cs_as_ks_ws,

hz2 nchar(1) collate chinese_prc_cs_as_ks_ws)

insert @py select 'a',n'吖',n'鏊'

union  all select 'b',n'八',n'簿'

union  all select 'c',n'嚓',n'錯'

union  all select 'd',n'噠',n'跺'

union  all select 'e',n'屙',n'貳'

union  all select 'f',n'發',n'馥'

union  all select 'g',n'旮',n'過'

union  all select 'h',n'鉿',n'蠖'

union  all select 'j',n'丌',n'竣'

union  all select 'k',n'咔',n'廓'

union  all select 'l',n'垃',n'雒'

union  all select 'm',n'媽',n'穆'

union  all select 'n',n'拿',n'糯'

union  all select 'o',n'噢',n'漚'

union  all select 'p',n'趴',n'曝'

union  all select 'q',n'七',n'群'

union  all select 'r',n'蚺',n'箬'

union  all select 's',n'仨',n'鎖'

union  all select 't',n'他',n'籜'

union  all select 'w',n'哇',n'鋈'

union  all select 'x',n'夕',n'蕈'

union  all select 'y',n'丫',n'蘊'

union  all select 'z',n'匝',n'做'

declare @i int

set @i=patindex('%[吖-做]%' collate chinese_prc_cs_as_ks_ws,@str)

while @i>0

select @str=replace(@str,substring(@str,@i,1),ch)

,@i=patindex('%[吖-做]%' collate chinese_prc_cs_as_ks_ws,@str)

from @py

where substring(@str,@i,1) between hz1 and hz2

return(@str)

end

獲取拼音碼 sql函式

create function dbo f util getpinyincode str nvarchar 4000 returns nvarchar 4000 asbegin declare word nchar 1 py nvarchar 4000 set py while len str 0 ...

Oracle獲取拼音碼函式

create or replace function f spellcn p1 varchar2,p2 int default 0 return varchar2 as 獲得漢字拼音首字母 入口引數 漢字字串 是否只取第乙個漢字的拼音首字母 char1 varchar2 2 char2 varcha...

得到漢字的拼音碼

create function f getpy str nvarchar 4000 returns nvarchar 4000 as begin declare strlen int,re nvarchar 4000 declare t table chr nchar 1 collate chine...