/* Create pinyin First letter function */
Create function [dbo]. [Fn_chinesetospell] (@strChinese varchar (500) = ")
Returns varchar (500)
As
Begin/* Function implementation Start */
declare @strLen int, @return varchar ($), @i int
DECLARE @n int,@c char (1), @chn nchar (1)
Select @strLen =len (@strChinese), @return = ", @i=0
While @i< @strLen
Begin/*while Cycle Start */
Select @[email protected]+1,@n=63, @chn =substring (@strChinese, @i,1)
If @chn > ' z '/* principle: "string sorting and ASCII code table" */
Select @n = @n +1,@c =case CHN when @chn then char (@n) Else @c end from (select-Top + from (select CHN = ' acridine ' UNION ALL s) Elect ' Eight ' union all select ' Cha ' union ALL Select ' Otah ' union ALL SELECT ' Ehegan ' union ALL SELECT ' Send ' union ALL select ' Xu ' Unio n All select ' hafnium ' union ALL SELECT ' not '/*because have no ' I '/UNION ALL SELECT ' NOT ' union ALL select ' KA ' UNION ALL Select ' Garbage ' union ALL SELECT ' 嘸 ' union ALL SELECT ' Hallasan ' UNION ALL SELECT ' Oh ' UNION ALL SELECT ' 妑 ' UNION ALL select ' Seven ' UNION ALL SEL ECT ' 呥 ' UNION ALL SELECT ' Three ' union ALL select ' He ' union ALL select ' 屲 '/*no ' u ' */UNION ALL SELECT ' 屲 '/*no ' V ' */union AL L SELECT ' 屲 ' union ALL SELECT ' XI ' union ALL Select ' Ya ' union ALL SELECT ' as ' union ALL select @chn) as a order by CHN COLL ATE chinese_prc_ci_as) as B
Else
Set @[email protected]
Set @[email Protected][email protected]
End/*while Cycle Ends */
Return (@return)
End/* Function implementation ends */
SELECT [dbo]. [Fn_chinesetospell] (' plumbing ')
SQL Kanji to Pinyin