sql server 替换特殊符号

--create
-- 去掉特殊符号
alter function RepSymbol(@str nvarchar(max))
returns nvarchar(max)
as
begin

set @str=LTRIM(@str)
set @str=RTRIM(@str)
set @str=replace(@str,char(9),'') --水平制表符
set @str=replace(@str,char(10),'') -- 换行
set @str=replace(@str,char(13),'') --回车 
set @str = replace(@str,'π', 'π'); 
set @str = replace(@str,'∠', '');
set @str = replace(@str,'≠', '');
set @str = replace(@str,'≥', '');
set @str = replace(@str,'≤', '');
set @str = replace(@str,'α', 'α');
set @str = replace(@str,'|', '|');
set @str = replace(@str,'±', '±');
set @str = replace(@str,'∞', '');
set @str = replace(@str,'×', '×');
set @str = replace(@str,'$', '$');
set @str = replace(@str,''', '''');
set @str = replace(@str,'°','°');
set @str = replace(@str,'⊥','');
set @str = replace(@str,'∪','');
set @str = replace(@str,' ',' ');
set @str = replace(@str,'&lt;','<');
set @str = replace(@str,'&isin;','');
set @str = replace(@str,'&beta;','β');
set @str = replace(@str,'&#28635;','');
set @str = replace(@str,'&ldquo;','');
set @str = replace(@str,'&prime;','');
set @str = replace(@str,'&Delta;','Δ');     
set @str = replace(@str,'&middot;','·');     
set @str = replace(@str,'&gt;','>');
set @str = replace(@str,'&darr;','');
set @str = replace(@str,'&rarr;','');
set @str = replace(@str,'&bull;',''); 
set @str = replace(@str,'&rdquo;',''); 
set @str = replace(@str,'&omega;','ω'); 
set @str = replace(@str,'&shy;',''); 
set @str = replace(@str,'&uarr;',''); 
set @str = replace(@str,'&theta;','θ'); 
set @str = replace(@str,'&mdash;',''); 
set @str = replace(@str,'&#8212;',''); 
set @str = replace(@str,'&#36','$');
set @str = replace(@str,'&#9661;','');    
set @str = replace(@str,'&there4;','');    
set @str = replace(@str,'&#8853;','');    
set @str = replace(@str,'&zeta;','ζ');
set @str = replace(@str,'&#32;','');    
set @str = replace(@str,'&cap;','');    
set @str = replace(@str,'&hellip;','');    
set @str = replace(@str,'&#30771;','');    
set @str = replace(@str,'&rho;','ρ');    
set @str = replace(@str,'&divide;','÷');    
set @str = replace(@str,'&gamma;','γ');    
set @str = replace(@str,'&#8805;','');    
set @str = replace(@str,'&#183;','·');    
set @str = replace(@str,'&#39','''');    
set @str = replace(@str,'&quot;','"');    

set @str=replace(@str,'&forall;','');
set @str=replace(@str,'&part;','');
set @str=replace(@str,'&empty;','');
set @str=replace(@str,'&nabla;','');
set @str=replace(@str,'&isin;','');
set @str=replace(@str,'&notin;','');
set @str=replace(@str,'&ni;','');
set @str=replace(@str,'&prod;','');
set @str=replace(@str,'&sum;','');
set @str=replace(@str,'&minus;','');
set @str=replace(@str,'&lowast;','');
set @str=replace(@str,'&radic;','');
set @str=replace(@str,'&prop;','');
set @str=replace(@str,'&infin;','');
set @str=replace(@str,'&ang;','');
set @str=replace(@str,'&and;','');
set @str=replace(@str,'&or;','');
set @str=replace(@str,'&cap;','');
set @str=replace(@str,'&cup;','');
set @str=replace(@str,'&int;','');
set @str=replace(@str,'&there4;','');
set @str=replace(@str,'&sim;','');
set @str=replace(@str,'&cong;','');
set @str=replace(@str,'&asymp;','');
set @str=replace(@str,'&ne;','');
set @str=replace(@str,'&equiv;','');
set @str=replace(@str,'&le;','');
set @str=replace(@str,'&ge;','');
set @str=replace(@str,'&sub;','');
set @str=replace(@str,'&sup;','');
set @str=replace(@str,'&nsub;','');
set @str=replace(@str,'&sube;','');
set @str=replace(@str,'&supe;','');
set @str=replace(@str,'&oplus;','');
set @str=replace(@str,'&otimes;','');
set @str=replace(@str,'&perp;','');
set @str=replace(@str,'&sdot;','');
set @str=replace(@str,'&Alpha;','Α');
set @str=replace(@str,'&Beta;','Β');
set @str=replace(@str,'&Gamma;','Γ');
set @str=replace(@str,'&Delta;','Δ');
set @str=replace(@str,'&Epsilon;','Ε');
set @str=replace(@str,'&Zeta;','Ζ');
set @str=replace(@str,'&Eta;','Η');
set @str=replace(@str,'&Theta;','Θ');
set @str=replace(@str,'&Iota;','Ι');
set @str=replace(@str,'&Kappa;','Κ');
set @str=replace(@str,'&Lambda;','Λ');
set @str=replace(@str,'&Mu;','Μ');
set @str=replace(@str,'&Nu;','Ν');
set @str=replace(@str,'&Xi;','Ξ');
set @str=replace(@str,'&Omicron;','Ο');
set @str=replace(@str,'&Pi;','Π');
set @str=replace(@str,'&Rho;','Ρ');
set @str=replace(@str,'&Sigma;','Σ');
set @str=replace(@str,'&Tau;','Τ');
set @str=replace(@str,'&Upsilon;','Υ');
set @str=replace(@str,'&Phi;','Φ');
set @str=replace(@str,'&Chi;','Χ');
set @str=replace(@str,'&Psi;','Ψ');
set @str=replace(@str,'&Omega;','Ω');
set @str=replace(@str,'&alpha;','α');
set @str=replace(@str,'&beta;','β');
set @str=replace(@str,'&gamma;','γ');
set @str=replace(@str,'&delta;','δ');
set @str=replace(@str,'&epsilon;','ε');
set @str=replace(@str,'&zeta;','ζ');
set @str=replace(@str,'&eta;','η');
set @str=replace(@str,'&theta;','θ');
set @str=replace(@str,'&iota;','ι');
set @str=replace(@str,'&kappa;','κ');
set @str=replace(@str,'&lambda;','λ');
set @str=replace(@str,'&mu;','μ');
set @str=replace(@str,'&nu;','ν');
set @str=replace(@str,'&xi;','ξ');
set @str=replace(@str,'&omicron;','ο');
set @str=replace(@str,'&pi;','π');
set @str=replace(@str,'&rho;','ρ');
set @str=replace(@str,'&sigmaf;','ς');
set @str=replace(@str,'&sigma;','σ');
set @str=replace(@str,'&tau;','τ');
set @str=replace(@str,'&upsilon;','υ');
set @str=replace(@str,'&phi;','φ');
set @str=replace(@str,'&chi;','χ');
set @str=replace(@str,'&psi;','ψ');
set @str=replace(@str,'&omega;','ω');
set @str=replace(@str,'&thetasym;','ϑ');
set @str=replace(@str,'&upsih;','ϒ');
set @str=replace(@str,'&piv;','ϖ');
set @str=replace(@str,'&OElig;','Œ');
set @str=replace(@str,'&oelig;','œ');
set @str=replace(@str,'&Scaron;','Š');
set @str=replace(@str,'&scaron;','š');
set @str=replace(@str,'&Yuml;','Ÿ');
set @str=replace(@str,'&fnof;','ƒ');
set @str=replace(@str,'&circ;','ˆ');
set @str=replace(@str,'&tilde;','˜');
set @str=replace(@str,'&ensp;','');
set @str=replace(@str,'&emsp;','');
set @str=replace(@str,'&thinsp;','');
set @str=replace(@str,'&zwnj;','');
set @str=replace(@str,'&zwj;','');
set @str=replace(@str,'&lrm;','');
set @str=replace(@str,'&rlm;','');
set @str=replace(@str,'&ndash;','');
set @str=replace(@str,'&mdash;','');
set @str=replace(@str,'&lsquo;','');
set @str=replace(@str,'&rsquo;','');
set @str=replace(@str,'&sbquo;','');
set @str=replace(@str,'&ldquo;','');
set @str=replace(@str,'&rdquo;','');
set @str=replace(@str,'&bdquo;','');
set @str=replace(@str,'&dagger;','');
set @str=replace(@str,'&Dagger;','');
set @str=replace(@str,'&bull;','');
set @str=replace(@str,'&hellip;','');
set @str=replace(@str,'&permil;','');
set @str=replace(@str,'&prime;','');
set @str=replace(@str,'&Prime;','');
set @str=replace(@str,'&lsaquo;','');
set @str=replace(@str,'&rsaquo;','');
set @str=replace(@str,'&oline;','');
set @str=replace(@str,'&euro;','');
set @str=replace(@str,'&trade;','');
set @str=replace(@str,'&larr;','');
set @str=replace(@str,'&uarr;','');
set @str=replace(@str,'&rarr;','');
set @str=replace(@str,'&darr;','');
set @str=replace(@str,'&harr;','');
set @str=replace(@str,'&crarr;','');
set @str=replace(@str,'&lceil;','');
set @str=replace(@str,'&rceil;','');
set @str=replace(@str,'&lfloor;','');
set @str=replace(@str,'&rfloor;','');
set @str=replace(@str,'&loz;','');
set @str=replace(@str,'&spades;','');
set @str=replace(@str,'&clubs;','');
set @str=replace(@str,'&hearts;','');
set @str=replace(@str,'&diams;',''); 
set @str=replace(@str,'&#8704;','');


set @str=replace(@str,'&#8706;','');
set @str=replace(@str,'&#8707;','');
set @str=replace(@str,'&#8709;','');
set @str=replace(@str,'&#8711;','');
set @str=replace(@str,'&#8712;','');
set @str=replace(@str,'&#8713;','');
set @str=replace(@str,'&#8715;','');
set @str=replace(@str,'&#8719;','');
set @str=replace(@str,'&#8721;','');
set @str=replace(@str,'&#8722;','');
set @str=replace(@str,'&#8727;','');
set @str=replace(@str,'&#8730;','');
set @str=replace(@str,'&#8733;','');
set @str=replace(@str,'&#8734;','');
set @str=replace(@str,'&#8736;','');
set @str=replace(@str,'&#8743;','');
set @str=replace(@str,'&#8744;','');
set @str=replace(@str,'&#8745;','');
set @str=replace(@str,'&#8746;','');
set @str=replace(@str,'&#8747;','');
set @str=replace(@str,'&#8756;','');
set @str=replace(@str,'&#8764;','');
set @str=replace(@str,'&#8773;','');
set @str=replace(@str,'&#8776;','');
set @str=replace(@str,'&#8800;','');
set @str=replace(@str,'&#8801;','');
set @str=replace(@str,'&#8804;','');
set @str=replace(@str,'&#8805;','');
set @str=replace(@str,'&#8834;','');
set @str=replace(@str,'&#8835;','');
set @str=replace(@str,'&#8836;','');
set @str=replace(@str,'&#8838;','');
set @str=replace(@str,'&#8839;','');
set @str=replace(@str,'&#8853;','');
set @str=replace(@str,'&#8855;','');
set @str=replace(@str,'&#8869;','');
set @str=replace(@str,'&#8901;','');
set @str=replace(@str,'&#913;','Α');
set @str=replace(@str,'&#914;','Β');
set @str=replace(@str,'&#915;','Γ');
set @str=replace(@str,'&#916;','Δ');
set @str=replace(@str,'&#917;','Ε');
set @str=replace(@str,'&#918;','Ζ');
set @str=replace(@str,'&#919;','Η');
set @str=replace(@str,'&#920;','Θ');
set @str=replace(@str,'&#921;','Ι');
set @str=replace(@str,'&#922;','Κ');
set @str=replace(@str,'&#923;','Λ');
set @str=replace(@str,'&#924;','Μ');
set @str=replace(@str,'&#925;','Ν');
set @str=replace(@str,'&#926;','Ξ');
set @str=replace(@str,'&#927;','Ο');
set @str=replace(@str,'&#928;','Π');
set @str=replace(@str,'&#929;','Ρ');
set @str=replace(@str,'&#931;','Σ');
set @str=replace(@str,'&#932;','Τ');
set @str=replace(@str,'&#933;','Υ');
set @str=replace(@str,'&#934;','Φ');
set @str=replace(@str,'&#935;','Χ');
set @str=replace(@str,'&#936;','Ψ');
set @str=replace(@str,'&#937;','Ω');
set @str=replace(@str,'&#945;','α');
set @str=replace(@str,'&#946;','β');
set @str=replace(@str,'&#947;','γ');
set @str=replace(@str,'&#948;','δ');
set @str=replace(@str,'&#949;','ε');
set @str=replace(@str,'&#950;','ζ');
set @str=replace(@str,'&#951;','η');
set @str=replace(@str,'&#952;','θ');
set @str=replace(@str,'&#953;','ι');
set @str=replace(@str,'&#954;','κ');
set @str=replace(@str,'&#923;','λ');
set @str=replace(@str,'&#956;','μ');
set @str=replace(@str,'&#925;','ν');
set @str=replace(@str,'&#958;','ξ');
set @str=replace(@str,'&#959;','ο');
set @str=replace(@str,'&#960;','π');
set @str=replace(@str,'&#961;','ρ');
set @str=replace(@str,'&#962;','ς');
set @str=replace(@str,'&#963;','σ');
set @str=replace(@str,'&#964;','τ');
set @str=replace(@str,'&#965;','υ');
set @str=replace(@str,'&#966;','φ');
set @str=replace(@str,'&#967;','χ');
set @str=replace(@str,'&#968;','ψ');
set @str=replace(@str,'&#969;','ω');
set @str=replace(@str,'&#977;','ϑ');
set @str=replace(@str,'&#978;','ϒ');
set @str=replace(@str,'&#982;','ϖ');
set @str=replace(@str,'&#338;','Œ');
set @str=replace(@str,'&#339;','œ');
set @str=replace(@str,'&#352;','Š');
set @str=replace(@str,'&#353;','š');
set @str=replace(@str,'&#376;','Ÿ');
set @str=replace(@str,'&#402;','ƒ');
set @str=replace(@str,'&#710;','ˆ');
set @str=replace(@str,'&#732;','˜');
set @str=replace(@str,'&#8194;','');
set @str=replace(@str,'&#8195;','');
set @str=replace(@str,'&#8201;','');
set @str=replace(@str,'&#8204;','');
set @str=replace(@str,'&#8205;','');
set @str=replace(@str,'&#8206;','');
set @str=replace(@str,'&#8207;','');
set @str=replace(@str,'&#8211;','');
set @str=replace(@str,'&#8212;','');
set @str=replace(@str,'&#8216;','');
set @str=replace(@str,'&#8217;','');
set @str=replace(@str,'&#8218;','');
set @str=replace(@str,'&#8220;','');
set @str=replace(@str,'&#8221;','');
set @str=replace(@str,'&#8222;','');
set @str=replace(@str,'&#8224;','');
set @str=replace(@str,'&#8225;','');
set @str=replace(@str,'&#8226;','');
set @str=replace(@str,'&#8230;','');
set @str=replace(@str,'&#8240;','');
set @str=replace(@str,'&#8242;','');
set @str=replace(@str,'&#8243;','');
set @str=replace(@str,'&#8249;','');
set @str=replace(@str,'&#8250;','');
set @str=replace(@str,'&#8254;','');
set @str=replace(@str,'&#8364;','');
set @str=replace(@str,'&#8482;','');
set @str=replace(@str,'&#8592;','');
set @str=replace(@str,'&#8593;','');
set @str=replace(@str,'&#8594;','');
set @str=replace(@str,'&#8595;','');
set @str=replace(@str,'&#8596;','');
set @str=replace(@str,'&#8629;','');
set @str=replace(@str,'&#8968;','');
set @str=replace(@str,'&#8969;','');
set @str=replace(@str,'&#8970;','');
set @str=replace(@str,'&#8971;','');
set @str=replace(@str,'&#9674;','');
set @str=replace(@str,'&#9824;','');
set @str=replace(@str,'&#9827;','');
set @str=replace(@str,'&#9829;','');
set @str=replace(@str,'&#9830;','');
return @str 
end
go

 

posted @ 2016-09-03 09:44  胡一飘  阅读(3553)  评论(0编辑  收藏  举报