
{"id":1028,"date":"2021-10-20T19:17:11","date_gmt":"2021-10-20T11:17:11","guid":{"rendered":"http:\/\/dba.qishuo.xin\/?p=1028"},"modified":"2021-10-20T19:19:56","modified_gmt":"2021-10-20T11:19:56","slug":"sqlserver%e8%bd%ac%e6%8d%a2%e5%85%a8%e8%a7%92%e5%92%8c%e5%8d%8a%e8%a7%92%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"http:\/\/dba.qishuo.xin\/?p=1028","title":{"rendered":"SQLServer\u8f6c\u6362\u5168\u89d2\u548c\u534a\u89d2\u51fd\u6570"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_76 ez-toc-wrap-right counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<label for=\"ez-toc-cssicon-toggle-item-69e1f2913e6c6\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69e1f2913e6c6\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"http:\/\/dba.qishuo.xin\/?p=1028\/#1_%E5%88%9B%E5%BB%BA%E5%87%BD%E6%95%B0\" >1. \u521b\u5efa\u51fd\u6570<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"http:\/\/dba.qishuo.xin\/?p=1028\/#2_%E8%B0%83%E7%94%A8%E6%96%B9%E6%B3%95\" >2. \u8c03\u7528\u65b9\u6cd5<\/a><\/li><\/ul><\/nav><\/div>\n<h4><span class=\"ez-toc-section\" id=\"1_%E5%88%9B%E5%BB%BA%E5%87%BD%E6%95%B0\"><\/span>1. \u521b\u5efa\u51fd\u6570<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-sql line-numbers\">CREATE FUNCTION Fn_Convert_Semiangle(\n  @str nvarchar(4000), --\u8981\u8f6c\u6362\u7684\u5b57\u7b26\u4e32\n  @flag bit            --\u8f6c\u6362\u6807\u5fd7,0\u8f6c\u6362\u6210\u534a\u89d2,1\u8f6c\u6362\u6210\u5168\u89d2\n) RETURNS nvarchar(4000)\nAS\nBEGIN\n DECLARE @pat nvarchar(8),@step int,@i int,@spc int\n\n IF @flag=0\n   SELECT @pat=N'%[\uff01-\uff5e]%', @step=-65248, @str=REPLACE(@str,N'\u3000 ',N' ');\n ELSE\n   SELECT @pat=N'%[!-~]%', @step=65248, @str=REPLACE(@str,N' ',N'\u3000 ');\n\n SET @i = PATINDEX(@pat COLLATE LATIN1_GENERAL_BIN, @str);\n\n WHILE @i &gt; 0\n  SELECT @str=REPLACE(@str\n                     ,SUBSTRING(@str,@i,1)\n                     ,NCHAR(UNICODE(SUBSTRING(@str,@i,1))+@step))\n                     ,@i=PATINDEX(@pat COLLATE LATIN1_GENERAL_BIN\n                     ,@str);\n RETURN(@str);\nEND;\nGO\n<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"2_%E8%B0%83%E7%94%A8%E6%96%B9%E6%B3%95\"><\/span>2. \u8c03\u7528\u65b9\u6cd5<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-sql line-numbers\"> DECLARE @s1 varchar(8000);\n SET @s1='\u4e2d   \u3000\uff12-\uff13\uff14\uff15\uff16a\uff17\uff18\uff33\uff34\uff35\uff36ab\uff4e\u4e2d\u56fd\uff4f\uff50\uff57\uff58\uff59\uff5a';\n SELECT dbo.Fn_Convert_Semiangle(@s1,0) AS \u8f6c\u534a\u89d2,dbo.Fn_Convert_Semiangle(@s1,1) AS \u8f6c\u5168\u89d2;\n<\/code><\/pre>\n<p><a href=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2021\/10\/wp_editor_md_8c3a67950d792bab07833066eba62940.jpg\" data-fancybox=\"images\" data-fancybox=\"images\"><img decoding=\"async\" src=\"http:\/\/dba.qishuo.xin\/wp-content\/uploads\/2021\/10\/wp_editor_md_8c3a67950d792bab07833066eba62940.jpg\" alt=\"\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u521b\u5efa\u51fd\u6570 CREATE FUNCTION F&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[140,141,142],"class_list":["post-1028","post","type-post","status-publish","format-standard","hentry","category-sqlserver","tag-sqlserver","tag-141","tag-142"],"_links":{"self":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/1028","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1028"}],"version-history":[{"count":3,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/1028\/revisions"}],"predecessor-version":[{"id":1031,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/1028\/revisions\/1031"}],"wp:attachment":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1028"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1028"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1028"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}