Function:
/*To create a phonetic first letter function*/ Create function [dbo].[Fn_chinesetospell](@strChinese varchar( -)="') returns varchar( -) as begin /*function Implementation begins*/ 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 Loop starts*/ Select @i=@i+1,@n= the,@chn=substring(@strChinese,@i,1) if @chn>'Z'/*principle: "String sorting and ASCII code table"*/ Select @n = @n +1,@c = CaseChn when @chn Then Char(@n)Else @c End from(Select Top - * from(SelectChn= 'Acridine' Union All Select 'Eight' Union All Select 'Cha' Union All Select 'Otah' Union All Select 'Ehegan' Union All Select 'Hair' Union All Select 'Xu' Union 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 Select '呥' Union All Select 'SA' Union All Select 'his' Union All Select '屲' /*no ' u '*/ Union All Select '屲' /*No ' V '*/ Union All Select '屲' Union All Select 'XI' Union All Select 'ya' Union All Select 'as' Union All Select @chn) asAOrder byCHN COLLATE chinese_prc_ci_as) asbElse Set @c=@chn Set @return=@return+@c End /*While Loop ends*/ return(@return) End /*End of function implementation*/
How to use:
UPDATE SET = Dbo.fn_chinesetospell (Name)
SQL SERVER functions to get phonetic abbreviations