http://blog.csdn.net/zhanglong_longlong/article/details/46772571
--can support 20,000 characters of large character set!CreatefunctionF_ch2py (@chn nchar (1)) returns char (1) asbeginDeclare@n intDeclare@c Char (1) Set @n= 63Select @n= @n +1,@c= CaseCHN when @chn then char (@n)Else@cEndFrom (select top27 *From (select CHN= ' Acridine 'UNION ALL SelectEightUNION ALL SelectChaUNION ALL SelectOtahUNION ALL SelectEheganUNION ALL SelectHairUNION ALL SelectXuUNION ALL SelectHafniumUNION ALL Select' Not ' union ALL select--because has no ' i 'UNION ALL SelectCarbazoleUNION ALL SelectLaUNION ALL Select' 嘸 'UNION ALL SelectHallasanUNION ALL SelectOhUNION ALL Select' 妑 'UNION ALL SelectSevenUNION ALL Select' 呥 'UNION ALL SelectThreeUNION ALL SelectHeUNION ALL Select' 屲 ' UNION ALL select--no ' u ' 屲 ' UNION ALL select--no ' V ' 屲 'UNION ALL SelectYubariUNION ALL SelectYaUNION ALL Select' As ' union ALL select @chn) asAorder by CHN COLLATE chinese_prc_ci_as) asbreturn(@c)Endgoselect dbo. f_ch2py (' Medium ')--zselect dbo. F_ch2py (' country ')--gselect dbo. F_ch2py (' People ')--rselect dbo. F_ch2py (' HSW ')--Mgo-----------------Call CreateFUNCTIONF_gethelpcode (@cName VARCHAR (20)) RETURNS VARCHAR (12) asBEGINDECLARE@i SMALLINT, @l SMALLINT, @cHelpCode varchar (), @e varchar (12),@iAscii SMALLINT SELECT @i=1, @l=0, @cHelpCode = " while@l<=12 and @i<=LEN (@cName) BEGIN SELECT @e=lower (SUBSTRING (@cname, @i,1)) SELECT @iAscii=ASCII (@e)IF@iAscii >=48 and @iAscii <=57 or @iAscii >=97 and @iAscii <=122 or @iAscii =95SELECT @cHelpCode[Email protected] +@eELSE IF@iAscii >=176 and @iAscii <=247SELECT @cHelpCode[Email protected] + dbo.f_ch2py (@e)ELSESELECT @[email protected]SELECT @i[Email protected]+1, @[email protected]+1END RETURN@cHelpCodeENDGO--Call SELECT dbo. F_gethelpcode (' vigorously ')
SQL Chinese to Pinyin first letter