原文: http://www.voidcn.com/article/p-dpsmzzev-baq.html
最近用到项目,当输入错别字时也需要匹配,直接网上找到一篇直接改写加了拼音排序,让语句更通用。拿来主义
[sql] view plain copy USE Test go IF OBJECT_ID('Fn_GetQuanPin','Fn') IS NOT NulL DROP FUNCTION fn_GetQuanPin create function [dbo].[fn_GetQuanPin](@str varchar(100)) returns varchar(8000) @H_419_109@as begin declare @re varchar(8000),@crs varchar(10) declare @strlen int @H_419_109@select @strlen=len(@str),@re='' while @strlen>0 @H_419_109@begin set @crs= substring(@str,@strlen,1) select @re= CASE when @crs<'吖' ColLATE Chinese_PRC_CS_AS_KS_WS then @crs when @crs<='厑' then 'A' @H_419_109@when @crs<='靉' then 'Ai' when @crs<='黯' then 'An' @H_419_109@when @crs<='醠' then 'Ang' when @crs<='驁' then 'Ao' @H_419_109@when @crs<='欛' then 'Ba' when @crs<='瓸' then 'Bai' @H_419_109@when @crs<='瓣' then 'Ban' when @crs<='鎊' then 'Bang' @H_419_109@when @crs<='鑤' then 'Bao' when @crs<='鐾' then 'Bei' @H_419_109@when @crs<='輽' then 'Ben' when @crs<='鏰' then 'Beng' @H_419_109@when @crs<='鼊' then 'Bi' when @crs<='變' then 'Bian' @H_419_109@when @crs<='鰾' then 'Biao' when @crs<='彆' then 'BIE' @H_419_109@when @crs<='鬢' then 'Bin' when @crs<='靐' then 'Bing' @H_419_109@when @crs<='蔔' then 'Bo' when @crs<='簿' then 'Bu' @H_419_109@when @crs<='囃' then 'Ca' when @crs<='乲' then 'Cai' @H_419_109@when @crs<='爘' then 'Can' when @crs<='賶' then 'Cang' @H_419_109@when @crs<='鼜' then 'Cao' when @crs<='簎' then 'Ce' @H_419_109@when @crs<='笒' then 'Cen' when @crs<='乽' then 'Ceng' @H_419_109@when @crs<='詫' then 'Cha' when @crs<='囆' then 'Chai' @H_419_109@when @crs<='顫' then 'Chan' when @crs<='韔' then 'Chang' @H_419_109@when @crs<='觘' then 'Chao' when @crs<='爡' then 'Che' @H_419_109@when @crs<='讖' then 'Chen' when @crs<='秤' then 'Cheng' @H_419_109@when @crs<='鷘' then 'Chi' when @crs<='銃' then 'Chong' @H_419_109@when @crs<='殠' then 'Chou' when @crs<='矗' then 'Chu' @H_419_109@when @crs<='踹' then 'Chuai' when @crs<='鶨' then 'Chuan' @H_419_109@when @crs<='愴' then 'Chuang' when @crs<='顀' then 'Chui' @H_419_109@when @crs<='蠢' then 'Chun' when @crs<='縒' then 'Chuo' @H_419_109@when @crs<='嗭' then 'Ci' when @crs<='謥' then 'Cong' @H_419_109@when @crs<='輳' then 'Cou' when @crs<='顣' then 'Cu' @H_419_109@when @crs<='爨' then 'cuan' when @crs<='臎' then 'Cui' @H_419_109@when @crs<='籿' then 'Cun' when @crs<='錯' then 'Cuo' @H_419_109@when @crs<='橽' then 'Da' when @crs<='靆' then 'Dai' @H_419_109@when @crs<='饏' then 'Dan' when @crs<='闣' then 'Dang' @H_419_109@when @crs<='纛' then 'Dao' when @crs<='的' then 'De' @H_419_109@when @crs<='扽' then 'Den' when @crs<='鐙' then 'Deng' @H_419_109@when @crs<='螮' then 'Di' when @crs<='嗲' then 'Dia' @H_419_109@when @crs<='驔' then 'Dian' when @crs<='鑃' then 'Diao' @H_419_109@when @crs<='嚸' then 'DIE' when @crs<='顁' then 'Ding' @H_419_109@when @crs<='銩' then 'Diu' when @crs<='霘' then 'Dong' @H_419_109@when @crs<='鬭' then 'Dou' when @crs<='蠹' then 'Du' @H_419_109@when @crs<='叾' then 'Duan' when @crs<='譵' then 'Dui' @H_419_109@when @crs<='踲' then 'Dun' when @crs<='鵽' then 'Duo' @H_419_109@when @crs<='鱷' then 'E' when @crs<='摁' then 'En' @H_419_109@when @crs<='鞥' then 'Eng' when @crs<='樲' then 'Er' @H_419_109@when @crs<='髮' then 'Fa' when @crs<='瀪' then 'Fan' @H_419_109@when @crs<='放' then 'Fang' when @crs<='靅' then 'Fei' @H_419_109@when @crs<='鱝' then 'Fen' when @crs<='覅' then 'Feng' @H_419_109@when @crs<='梻' then 'Fo' when @crs<='鴀' then 'Fou' @H_419_109@when @crs<='猤' then 'Fu' when @crs<='魀' then 'Ga' @H_419_109@when @crs<='瓂' then 'Gai' when @crs<='灨' then 'Gan' @H_419_109@when @crs<='戇' then 'Gang' when @crs<='鋯' then 'Gao' @H_419_109@when @crs<='獦' then 'Ge' when @crs<='給' then 'Gei' @H_419_109@when @crs<='搄' then 'Gen' when @crs<='堩' then 'Geng' @H_419_109@when @crs<='兣' then 'Gong' when @crs<='購' then 'Gou' @H_419_109@when @crs<='顧' then 'Gu' when @crs<='詿' then 'Gua' @H_419_109@when @crs<='恠' then 'Guai' when @crs<='鱹' then 'Guan' @H_419_109@when @crs<='撗' then 'Guang' when @crs<='鱥' then 'Gui' @H_419_109@when @crs<='謴' then 'Gun' when @crs<='腂' then 'Guo' @H_419_109@when @crs<='哈' then 'Ha' when @crs<='饚' then 'Hai' @H_419_109@when @crs<='鶾' then 'Han' when @crs<='沆' then 'Hang' @H_419_109@when @crs<='兞' then 'Hao' when @crs<='靏' then 'He' @H_419_109@when @crs<='嬒' then 'Hei' when @crs<='恨' then 'Hen' @H_419_109@when @crs<='堼' then 'Heng' when @crs<='鬨' then 'Hong' @H_419_109@when @crs<='鱟' then 'Hou' when @crs<='鸌' then 'Hu' @H_419_109@when @crs<='蘳' then 'Hua' when @crs<='蘾' then 'Huai' @H_419_109@when @crs<='鰀' then 'Huan' when @crs<='鎤' then 'Huang' @H_419_109@when @crs<='顪' then 'Hui' when @crs<='諢' then 'Hun' @H_419_109@when @crs<='夻' then 'Huo' when @crs<='驥' then 'Ji' @H_419_109@when @crs<='嗧' then 'Jia' when @crs<='鑳' then 'Jian' @H_419_109@when @crs<='謽' then 'Jiang' when @crs<='釂' then 'Jiao' @H_419_109@when @crs<='繲' then 'JIE' when @crs<='齽' then 'Jin' @H_419_109@when @crs<='竸' then 'Jing' when @crs<='蘔' then 'Jiong' @H_419_109@when @crs<='欍' then 'Jiu' when @crs<='爠' then 'Ju' @H_419_109@when @crs<='羂' then 'Juan' when @crs<='钁' then 'Jue' @H_419_109@when @crs<='攈' then 'Jun' when @crs<='鉲' then 'Ka' @H_419_109@when @crs<='乫' then 'Kai' when @crs<='矙' then 'Kan' @H_419_109@when @crs<='閌' then 'Kang' when @crs<='鯌' then 'Kao' @H_419_109@when @crs<='騍' then 'Ke' when @crs<='褃' then 'Ken' @H_419_109@when @crs<='鏗' then 'Keng' when @crs<='廤' then 'Kong' @H_419_109@when @crs<='鷇' then 'Kou' when @crs<='嚳' then 'Ku' @H_419_109@when @crs<='骻' then 'Kua' when @crs<='鱠' then 'Kuai' @H_419_109@when @crs<='窾' then 'Kuan' when @crs<='鑛' then 'Kuang' @H_419_109@when @crs<='鑎' then 'Kui' when @crs<='睏' then 'Kun' @H_419_109@when @crs<='穒' then 'Kuo' when @crs<='鞡' then 'La' @H_419_109@when @crs<='籟' then 'Lai' when @crs<='糷' then 'Lan' @H_419_109@when @crs<='唥' then 'Lang' when @crs<='軂' then 'Lao' @H_419_109@when @crs<='餎' then 'Le' when @crs<='脷' then 'Lei' @H_419_109@when @crs<='睖' then 'Leng' when @crs<='瓈' then 'li' @H_419_109@when @crs<='倆' then 'lia' when @crs<='纞' then 'lian' @H_419_109@when @crs<='鍄' then 'liang' when @crs<='瞭' then 'liao' @H_419_109@when @crs<='鱲' then 'LIE' when @crs<='轥' then 'lin' @H_419_109@when @crs<='炩' then 'ling' when @crs<='咯' then 'liu' @H_419_109@when @crs<='贚' then 'Long' when @crs<='鏤' then 'Lou' @H_419_109@when @crs<='氇' then 'Lu' when @crs<='鑢' then 'Lv' @H_419_109@when @crs<='亂' then 'Luan' when @crs<='擽' then 'Lue' @H_419_109@when @crs<='論' then 'Lun' when @crs<='鱳' then 'Luo' @H_419_109@when @crs<='嘛' then 'Ma' when @crs<='霢' then 'Mai' @H_419_109@when @crs<='蘰' then 'Man' when @crs<='蠎' then 'Mang' @H_419_109@when @crs<='唜' then 'Mao' when @crs<='癦' then 'Me' @H_419_109@when @crs<='嚜' then 'Mei' when @crs<='們' then 'Men' @H_419_109@when @crs<='霥' then 'Meng' when @crs<='羃' then 'Mi' @H_419_109@when @crs<='麵' then 'Mian' when @crs<='廟' then 'Miao' @H_419_109@when @crs<='鱴' then 'MIE' when @crs<='鰵' then 'Min' @H_419_109@when @crs<='詺' then 'Ming' when @crs<='謬' then 'Miu' @H_419_109@when @crs<='耱' then 'Mo' when @crs<='麰' then 'Mou' @H_419_109@when @crs<='旀' then 'Mu' when @crs<='魶' then 'Na' @H_419_109@when @crs<='錼' then 'Nai' when @crs<='婻' then 'Nan' @H_419_109@when @crs<='齉' then 'Nang' when @crs<='臑' then 'Nao' @H_419_109@when @crs<='呢' then 'Ne' when @crs<='焾' then 'Nei' @H_419_109@when @crs<='嫩' then 'Nen' when @crs<='能' then 'Neng' @H_419_109@when @crs<='嬺' then 'Ni' when @crs<='艌' then 'Nian' @H_419_109@when @crs<='釀' then 'Niang' when @crs<='脲' then 'Niao' @H_419_109@when @crs<='钀' then 'NIE' when @crs<='拰' then 'Nin' @H_419_109@when @crs<='濘' then 'Ning' when @crs<='靵' then 'Niu' @H_419_109@when @crs<='齈' then 'Nong' when @crs<='譳' then 'Nou' @H_419_109@when @crs<='搙' then 'Nu' when @crs<='衄' then 'Nv' @H_419_109@when @crs<='瘧' then 'Nue' when @crs<='燶' then 'Nuan' @H_419_109@when @crs<='桛' then 'Nuo' when @crs<='鞰' then 'O' @H_419_109@when @crs<='漚' then 'Ou' when @crs<='袙' then 'Pa' @H_419_109@when @crs<='磗' then 'Pai' when @crs<='鑻' then 'Pan' @H_419_109@when @crs<='胖' then 'Pang' when @crs<='礮' then 'Pao' @H_419_109@when @crs<='轡' then 'Pei' when @crs<='喯' then 'Pen' @H_419_109@when @crs<='喸' then 'Peng' when @crs<='鸊' then 'Pi' @H_419_109@when @crs<='騙' then 'Pian' when @crs<='慓' then 'Piao' @H_419_109@when @crs<='嫳' then 'PIE' when @crs<='聘' then 'Pin' @H_419_109@when @crs<='蘋' then 'Ping' when @crs<='魄' then 'Po' @H_419_109@when @crs<='哛' then 'Pou' when @crs<='曝' then 'Pu' @H_419_109@when @crs<='蟿' then 'Qi' when @crs<='髂' then 'Qia' @H_419_109@when @crs<='縴' then 'Qian' when @crs<='瓩' then 'Qiang' @H_419_109@when @crs<='躈' then 'Qiao' when @crs<='籡' then 'QIE' @H_419_109@when @crs<='藽' then 'Qin' when @crs<='櫦' then 'Qing' @H_419_109@when @crs<='瓗' then 'Qiong' when @crs<='糗' then 'Qiu' @H_419_109@when @crs<='覻' then 'Qu' when @crs<='勸' then 'Quan' @H_419_109@when @crs<='礭' then 'Que' when @crs<='囕' then 'Qun' @H_419_109@when @crs<='橪' then 'Ran' when @crs<='讓' then 'Rang' @H_419_109@when @crs<='繞' then 'Rao' when @crs<='熱' then 'Re' @H_419_109@when @crs<='餁' then 'Ren' when @crs<='陾' then 'Reng' @H_419_109@when @crs<='馹' then 'Ri' when @crs<='穃' then 'Rong' @H_419_109@when @crs<='嶿' then 'Rou' when @crs<='擩' then 'Ru' @H_419_109@when @crs<='礝' then 'Ruan' when @crs<='壡' then 'Rui' @H_419_109@when @crs<='橍' then 'Run' when @crs<='鶸' then 'Ruo' @H_419_109@when @crs<='栍' then 'Sa' when @crs<='虄' then 'Sai' @H_419_109@when @crs<='閐' then 'San' when @crs<='喪' then 'Sang' @H_419_109@when @crs<='髞' then 'Sao' when @crs<='飋' then 'Se' @H_419_109@when @crs<='篸' then 'Sen' when @crs<='縇' then 'Seng' @H_419_109@when @crs<='霎' then 'Sha' when @crs<='曬' then 'Shai' @H_419_109@when @crs<='鱔' then 'Shan' when @crs<='緔' then 'Shang' @H_419_109@when @crs<='潲' then 'Shao' when @crs<='欇' then 'She' @H_419_109@when @crs<='瘮' then 'Shen' when @crs<='賸' then 'Sheng' @H_419_109@when @crs<='瓧' then 'Shi' when @crs<='鏉' then 'Shou' @H_419_109@when @crs<='虪' then 'Shu' when @crs<='誜' then 'Shua' @H_419_109@when @crs<='卛' then 'Shuai' when @crs<='腨' then 'Shuan' @H_419_109@when @crs<='灀' then 'Shuang' when @crs<='睡' then 'Shui' @H_419_109@when @crs<='鬊' then 'Shun' when @crs<='鑠' then 'Shuo' @H_419_109@when @crs<='乺' then 'Si' when @crs<='鎹' then 'Song' @H_419_109@when @crs<='瘶' then 'Sou' when @crs<='鷫' then 'Su' @H_419_109@when @crs<='算' then 'Suan' when @crs<='鐩' then 'Sui' @H_419_109@when @crs<='潠' then 'Sun' when @crs<='蜶' then 'Suo' @H_419_109@when @crs<='襨' then 'Ta' when @crs<='燤' then 'Tai' @H_419_109@when @crs<='賧' then 'Tan' when @crs<='燙' then 'Tang' @H_419_109@when @crs<='畓' then 'Tao' when @crs<='蟘' then 'Te' @H_419_109@when @crs<='朰' then 'Teng' when @crs<='趯' then 'Ti' @H_419_109@when @crs<='舚' then 'Tian' when @crs<='糶' then 'Tiao' @H_419_109@when @crs<='餮' then 'TIE' when @crs<='乭' then 'Ting' @H_419_109@when @crs<='憅' then 'Tong' when @crs<='透' then 'Tou' @H_419_109@when @crs<='鵵' then 'Tu' when @crs<='褖' then 'Tuan' @H_419_109@when @crs<='駾' then 'Tui' when @crs<='坉' then 'Tun' @H_419_109@when @crs<='籜' then 'Tuo' when @crs<='韤' then 'Wa' @H_419_109@when @crs<='顡' then 'Wai' when @crs<='贎' then 'Wan' @H_419_109@when @crs<='朢' then 'Wang' when @crs<='躛' then 'Wei' @H_419_109@when @crs<='璺' then 'Wen' when @crs<='齆' then 'Weng' @H_419_109@when @crs<='齷' then 'Wo' when @crs<='鶩' then 'Wu' @H_419_109@when @crs<='衋' then 'Xi' when @crs<='鏬' then 'Xia' @H_419_109@when @crs<='鼸' then 'Xian' when @crs<='鱌' then 'Xiang' @H_419_109@when @crs<='斆' then 'Xiao' when @crs<='躞' then 'XIE' @H_419_109@when @crs<='釁' then 'Xin' when @crs<='臖' then 'Xing' @H_419_109@when @crs<='敻' then 'Xiong' when @crs<='齅' then 'Xiu' @H_419_109@when @crs<='蓿' then 'Xu' when @crs<='贙' then 'Xuan' @H_419_109@when @crs<='瀥' then 'Xue' when @crs<='鑂' then 'Xun' @H_419_109@when @crs<='齾' then 'Ya' when @crs<='灩' then 'Yan' @H_419_109@when @crs<='樣' then 'Yang' when @crs<='鑰' then 'Yao' @H_419_109@when @crs<='岃' then 'Ye' when @crs<='齸' then 'Yi' @H_419_109@when @crs<='檼' then 'Yin' when @crs<='譍' then 'Ying' @H_419_109@when @crs<='喲' then 'Yo' when @crs<='醟' then 'Yong' @H_419_109@when @crs<='鼬' then 'You' when @crs<='爩' then 'Yu' @H_419_109@when @crs<='願' then 'Yuan' when @crs<='鸙' then 'Yue' @H_419_109@when @crs<='韻' then 'Yun' when @crs<='雥' then 'Za' @H_419_109@when @crs<='縡' then 'Zai' when @crs<='饡' then 'Zan' @H_419_109@when @crs<='臟' then 'Zang' when @crs<='竈' then 'Zao' @H_419_109@when @crs<='稄' then 'Ze' when @crs<='鱡' then 'Zei' @H_419_109@when @crs<='囎' then 'Zen' when @crs<='贈' then 'Zeng' @H_419_109@when @crs<='醡' then 'Zha' when @crs<='瘵' then 'Zhai' @H_419_109@when @crs<='驏' then 'Zhan' when @crs<='瞕' then 'Zhang' @H_419_109@when @crs<='羄' then 'Zhao' when @crs<='鷓' then 'Zhe' @H_419_109@when @crs<='黮' then 'Zhen' when @crs<='證' then 'Zheng' @H_419_109@when @crs<='豒' then 'Zhi' when @crs<='諥' then 'Zhong' @H_419_109@when @crs<='驟' then 'Zhou' when @crs<='鑄' then 'Zhu' @H_419_109@when @crs<='爪' then 'Zhua' when @crs<='跩' then 'Zhuai' @H_419_109@when @crs<='籑' then 'Zhuan' when @crs<='戅' then 'Zhuang' @H_419_109@when @crs<='鑆' then 'Zhui' when @crs<='稕' then 'Zhun' @H_419_109@when @crs<='籱' then 'Zhuo' when @crs<='漬' then 'Zi' @H_419_109@when @crs<='縱' then 'Zong' when @crs<='媰' then 'Zou' @H_419_109@when @crs<='謯' then 'Zu' when @crs<='攥' then 'Zuan' @H_419_109@when @crs<='欈' then 'Zui' when @crs<='銌' then 'Zun' @H_419_109@when @crs<='咗' then 'Zuo' else @crs end+@re,@strlen=@strlen-1 end return(@re) @H_419_109@END GO @H_419_109@SELECT dbo.fn_GetQuanPin('拿来主义') /* NaLaiZhuYi */
转载网址
总结以上是内存溢出为你收集整理的SQLServer汉字转全拼音函数全部内容,希望文章能够帮你解决SQLServer汉字转全拼音函数所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)