{"id":138901,"date":"2024-10-31T16:17:20","date_gmt":"2024-10-31T08:17:20","guid":{"rendered":"https:\/\/server.hk\/cnblog\/138901\/"},"modified":"2024-10-31T16:17:21","modified_gmt":"2024-10-31T08:17:21","slug":"sql-server%e6%aa%a2%e7%b4%a2ntext%e3%80%81text%e5%92%8cimage%e6%95%b8%e6%93%9a%e9%a1%9e%e5%9e%8b%e7%9a%84%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a0%85","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/138901\/","title":{"rendered":"SQL Server\u6aa2\u7d22ntext\u3001text\u548cimage\u6578\u64da\u985e\u578b\u7684\u6ce8\u610f\u4e8b\u9805"},"content":{"rendered":"<h1 id=\"sql-server%e6%aa%a2%e7%b4%a2ntext%e3%80%81text%e5%92%8cimage%e6%95%b8%e6%93%9a%e9%a1%9e%e5%9e%8b%e7%9a%84%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a0%85-QgzGQHxqjJ\">SQL Server\u6aa2\u7d22ntext\u3001text\u548cimage\u6578\u64da\u985e\u578b\u7684\u6ce8\u610f\u4e8b\u9805<\/h1>\n<p>\u5728SQL Server\u4e2d\uff0cntext\u3001text\u548cimage\u6578\u64da\u985e\u578b\u66fe\u7d93\u662f\u7528\u4f86\u5b58\u5132\u5927\u91cf\u6587\u672c\u548c\u4e8c\u9032\u5236\u6578\u64da\u7684\u4e3b\u8981\u9078\u64c7\u3002\u7136\u800c\uff0c\u96a8\u8457\u6280\u8853\u7684\u9032\u6b65\uff0c\u9019\u4e9b\u6578\u64da\u985e\u578b\u5df2\u7d93\u88ab\u66f4\u73fe\u4ee3\u7684\u6578\u64da\u985e\u578b\u6240\u53d6\u4ee3\uff0c\u5982nvarchar(max)\u3001varchar(max)\u548cvarbinary(max)\u3002\u5118\u7ba1\u5982\u6b64\uff0c\u4e86\u89e3\u9019\u4e9b\u820a\u6578\u64da\u985e\u578b\u7684\u7279\u6027\u548c\u4f7f\u7528\u6ce8\u610f\u4e8b\u9805\u4ecd\u7136\u5c0d\u65bc\u7dad\u8b77\u820a\u7cfb\u7d71\u6216\u9032\u884c\u6578\u64da\u9077\u79fb\u81f3\u95dc\u91cd\u8981\u3002<\/p>\n<h2 id=\"1-ntext%e3%80%81text%e5%92%8cimage%e7%9a%84%e5%9f%ba%e6%9c%ac%e6%a6%82%e5%bf%b5-QgzGQHxqjJ\">1. ntext\u3001text\u548cimage\u7684\u57fa\u672c\u6982\u5ff5<\/h2>\n<ul>\n<li><strong>ntext<\/strong>: \u7528\u65bc\u5b58\u5132Unicode\u5b57\u7b26\u7684\u9577\u6587\u672c\u6578\u64da\uff0c\u6700\u5927\u53ef\u90542^30-1\uff08\u7d041GB\uff09\u7684\u5b57\u7b26\u3002<\/li>\n<li><strong>text<\/strong>: \u7528\u65bc\u5b58\u5132\u975eUnicode\u5b57\u7b26\u7684\u9577\u6587\u672c\u6578\u64da\uff0c\u6700\u5927\u53ef\u90542^30-1\uff08\u7d041GB\uff09\u7684\u5b57\u7b26\u3002<\/li>\n<li><strong>image<\/strong>: \u7528\u65bc\u5b58\u5132\u4e8c\u9032\u5236\u6578\u64da\uff0c\u6700\u5927\u53ef\u90542^30-1\uff08\u7d041GB\uff09\u7684\u5b57\u7bc0\u3002<\/li>\n<\/ul>\n<p>\u9019\u4e9b\u6578\u64da\u985e\u578b\u7684\u4e3b\u8981\u7279\u9ede\u662f\u80fd\u5920\u5b58\u5132\u5927\u91cf\u6578\u64da\uff0c\u4f46\u5728\u4f7f\u7528\u6642\u9700\u8981\u6ce8\u610f\u4e00\u4e9b\u9650\u5236\u548c\u6027\u80fd\u554f\u984c\u3002<\/p>\n<h2 id=\"2-%e4%bd%bf%e7%94%a8%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a0%85-QgzGQHxqjJ\">2. \u4f7f\u7528\u6ce8\u610f\u4e8b\u9805<\/h2>\n<h3 id=\"2-1-%e6%80%a7%e8%83%bd%e5%95%8f%e9%a1%8c-QgzGQHxqjJ\">2.1 \u6027\u80fd\u554f\u984c<\/h3>\n<p>\u7531\u65bcntext\u3001text\u548cimage\u6578\u64da\u985e\u578b\u7684\u6578\u64da\u5b58\u5132\u5728\u4e0d\u540c\u7684\u9801\u9762\u4e0a\uff0c\u9019\u53ef\u80fd\u6703\u5c0e\u81f4\u6027\u80fd\u4e0b\u964d\u3002\u5728\u67e5\u8a62\u9019\u4e9b\u6578\u64da\u6642\uff0cSQL Server\u9700\u8981\u9032\u884c\u984d\u5916\u7684I\/O\u64cd\u4f5c\uff0c\u9019\u6703\u5f71\u97ff\u67e5\u8a62\u7684\u901f\u5ea6\u3002\u56e0\u6b64\uff0c\u5efa\u8b70\u5728\u53ef\u80fd\u7684\u60c5\u6cc1\u4e0b\u4f7f\u7528nvarchar(max)\u3001varchar(max)\u548cvarbinary(max)\u4f86\u66ff\u4ee3\u9019\u4e9b\u820a\u6578\u64da\u985e\u578b\u3002<\/p>\n<h3 id=\"2-2-%e4%b8%8d%e6%94%af%e6%8c%81%e7%9a%84%e6%93%8d%e4%bd%9c-QgzGQHxqjJ\">2.2 \u4e0d\u652f\u6301\u7684\u64cd\u4f5c<\/h3>\n<p>ntext\u3001text\u548cimage\u6578\u64da\u985e\u578b\u4e0d\u652f\u6301\u67d0\u4e9b\u64cd\u4f5c\uff0c\u4f8b\u5982\uff1a<\/p>\n<ul>\n<li>\u4e0d\u80fd\u4f7f\u7528LIKE\u904b\u7b97\u7b26\u9032\u884c\u6a21\u5f0f\u5339\u914d\u3002<\/li>\n<li>\u4e0d\u80fd\u76f4\u63a5\u4f7f\u7528SUBSTRING\u51fd\u6578\u3002<\/li>\n<li>\u4e0d\u80fd\u9032\u884c\u6392\u5e8f\u6216\u5206\u7d44\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<p>\u9019\u4e9b\u9650\u5236\u4f7f\u5f97\u5728\u8655\u7406\u9019\u4e9b\u6578\u64da\u985e\u578b\u6642\u9700\u8981\u984d\u5916\u7684\u8003\u91cf\uff0c\u7279\u5225\u662f\u5728\u8a2d\u8a08\u67e5\u8a62\u6642\u3002<\/p>\n<h3 id=\"2-3-%e6%95%b8%e6%93%9a%e9%81%b7%e7%a7%bb-QgzGQHxqjJ\">2.3 \u6578\u64da\u9077\u79fb<\/h3>\n<p>\u5728\u9032\u884c\u6578\u64da\u9077\u79fb\u6642\uff0c\u5c07ntext\u3001text\u548cimage\u6578\u64da\u985e\u578b\u8f49\u63db\u70ba\u65b0\u7684\u6578\u64da\u985e\u578b\u53ef\u80fd\u6703\u9047\u5230\u6311\u6230\u3002\u53ef\u4ee5\u4f7f\u7528CAST\u6216CONVERT\u51fd\u6578\u4f86\u9032\u884c\u8f49\u63db\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code>SELECT CAST(column_name AS nvarchar(max)) FROM table_name;<\/code><\/pre>\n<p>\u9019\u6a23\u53ef\u4ee5\u5c07ntext\u985e\u578b\u7684\u6578\u64da\u8f49\u63db\u70banvarchar(max)\u985e\u578b\uff0c\u5f9e\u800c\u63d0\u9ad8\u6027\u80fd\u548c\u53ef\u7528\u6027\u3002<\/p>\n<h2 id=\"3-%e6%9b%bf%e4%bb%a3%e6%96%b9%e6%a1%88-QgzGQHxqjJ\">3. \u66ff\u4ee3\u65b9\u6848<\/h2>\n<p>\u96a8\u8457SQL Server\u7684\u7248\u672c\u66f4\u65b0\uff0c\u5efa\u8b70\u4f7f\u7528\u4ee5\u4e0b\u6578\u64da\u985e\u578b\u4f86\u66ff\u4ee3ntext\u3001text\u548cimage\uff1a<\/p>\n<ul>\n<li><strong>nvarchar(max)<\/strong>: \u7528\u65bc\u5b58\u5132Unicode\u5b57\u7b26\u7684\u9577\u6587\u672c\u6578\u64da\uff0c\u652f\u6301\u6240\u6709\u7684\u5b57\u7b26\u4e32\u64cd\u4f5c\u3002<\/li>\n<li><strong>varchar(max)<\/strong>: \u7528\u65bc\u5b58\u5132\u975eUnicode\u5b57\u7b26\u7684\u9577\u6587\u672c\u6578\u64da\uff0c\u652f\u6301\u6240\u6709\u7684\u5b57\u7b26\u4e32\u64cd\u4f5c\u3002<\/li>\n<li><strong>varbinary(max)<\/strong>: \u7528\u65bc\u5b58\u5132\u4e8c\u9032\u5236\u6578\u64da\uff0c\u652f\u6301\u6240\u6709\u7684\u4e8c\u9032\u5236\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<p>\u9019\u4e9b\u65b0\u6578\u64da\u985e\u578b\u4e0d\u50c5\u63d0\u4f9b\u4e86\u66f4\u597d\u7684\u6027\u80fd\uff0c\u9084\u652f\u6301\u66f4\u591a\u7684\u64cd\u4f5c\uff0c\u80fd\u5920\u66f4\u597d\u5730\u6eff\u8db3\u73fe\u4ee3\u61c9\u7528\u7684\u9700\u6c42\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-QgzGQHxqjJ\">\u7e3d\u7d50<\/h2>\n<p>\u5728\u4f7f\u7528SQL Server\u6642\uff0c\u4e86\u89e3ntext\u3001text\u548cimage\u6578\u64da\u985e\u578b\u7684\u7279\u6027\u53ca\u5176\u4f7f\u7528\u6ce8\u610f\u4e8b\u9805\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u96d6\u7136\u9019\u4e9b\u6578\u64da\u985e\u578b\u5728\u67d0\u4e9b\u60c5\u6cc1\u4e0b\u4ecd\u7136\u53ef\u4ee5\u4f7f\u7528\uff0c\u4f46\u96a8\u8457\u6280\u8853\u7684\u9032\u6b65\uff0c\u5efa\u8b70\u9010\u6b65\u9077\u79fb\u5230\u66f4\u73fe\u4ee3\u7684\u6578\u64da\u985e\u578b\uff0c\u5982nvarchar(max)\u3001varchar(max)\u548cvarbinary(max)\u3002\u9019\u4e0d\u50c5\u80fd\u63d0\u9ad8\u6027\u80fd\uff0c\u9084\u80fd\u7c21\u5316\u6578\u64da\u64cd\u4f5c\u3002\u82e5\u60a8\u9700\u8981\u66f4\u591a\u6709\u95dc<em><a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a><\/em>\u548c<em><a href=\"https:\/\/server.hk\">\u4e91\u670d\u52a1\u5668<\/a><\/em>\u7684\u8cc7\u8a0a\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3SQL Server\u4e2dntext\u3001text\u548cimage\u6578\u64da\u985e\u578b\u7684\u6aa2\u7d22\u6ce8\u610f\u4e8b\u9805\uff0c\u78ba\u4fdd\u6578\u64da\u8655\u7406\u7684\u6548\u7387\u8207\u6e96\u78ba\u6027\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-138901","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/138901","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=138901"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/138901\/revisions"}],"predecessor-version":[{"id":138902,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/138901\/revisions\/138902"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=138901"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=138901"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=138901"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}