{"id":317396,"date":"2024-01-18T09:28:42","date_gmt":"2024-01-18T01:28:42","guid":{"rendered":"https:\/\/www.idc.net\/help\/317396\/"},"modified":"2024-01-18T09:28:42","modified_gmt":"2024-01-18T01:28:42","slug":"%e5%ae%9e%e7%8e%b0sql-server%e6%b5%b7%e9%87%8f%e6%95%b0%e6%8d%ae%e5%af%bc%e5%85%a5%e7%9a%84%e5%a5%bd%e7%94%a8%e6%96%b9%e6%a1%88","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/317396\/","title":{"rendered":"\u5b9e\u73b0SQL Server\u6d77\u91cf\u6570\u636e\u5bfc\u5165\u7684\u597d\u7528\u65b9\u6848"},"content":{"rendered":"<p>\u4ee5\u4e0b\u7684\u6587\u7ae0\u4e3b\u8981\u5411\u5927\u5bb6\u8bb2\u89e3\u7684\u662fSQL Server\u6d77\u91cf\u6570\u636e\u5bfc\u5165\u7684\u6700\u5feb***\u7528\u7684\u5b9e\u9645\u64cd\u4f5c\u65b9\u6cd5\uff0c\u5728\u5b9e\u9645\u64cd\u4f5c\u4e2d\u5c3c\u662f\u5426\u9047\u5230\u8fc7SQL Server\u6d77\u91cf\u6570\u636e\u5bfc\u5165\u8fd9\u4e00\u8981\u6c42\uff0c\u4ee5\u4e0b\u7684\u6587\u7ae0\u4e3b\u8981\u5411\u5927\u5bb6\u8bb2\u8ff0\u7684\u662f\u5b9e\u73b0\u5176\u5b9e\u9645\u64cd\u4f5c\u7684\u5177\u4f53\u65b9\u6848\u3002<\/p>\n<p>\u8fd9\u7bc7\u8bba\u575b\u6587\u7ae0\uff08\u8d5b\u8fea\u7f51\u6280\u672f\u793e\u533a\uff09\u8be6\u7ec6\u8bb2\u89e3\u4e86SQL Server\u6d77\u91cf\u6570\u636e\u5bfc\u5165\u7684\u6700\u5feb\u65b9\u6cd5\uff0c\u66f4\u591a\u5185\u5bb9\u8bf7\u53c2\u8003\u4e0b\u6587\uff1a<\/p>\n<p>\u6700\u8fd1\u505a\u67d0\u9879\u76ee\u7684\u6570\u636e\u5e93\u5206\u6790\uff0c\u8981\u5b9e\u73b0\u5bf9\u6d77\u91cf\u6570\u636e\u7684\u5bfc\u5165\u95ee\u9898\uff0c\u5c31\u662f\u6700\u591a\u628a200\u4e07\u6761\u6570\u636e\u4e00\u6b21\u5bfc\u5165sqlserver\u4e2d\uff0c\u5982\u679c\u4f7f\u7528\u666e\u901a\u7684insert\u8bed\u53e5\u8fdb\u884c\u5199\u51fa\u7684\u8bdd\uff0c\u6050\u6015\u6ca1\u4e2a\u628a\u5c0f\u65f6\u5b8c\u4e0d\u6210\u4efb\u52a1\uff0c\u5148\u662f\u8003\u8651\u4f7f\u7528bcp\uff0c\u4f46\u8fd9\u662f\u57fa\u4e8e\u547d\u4ee4\u884c\u7684\uff0c\u5bf9\u7528\u6237\u6765\u8bf4\u53cb\u597d\u6027\u592a\u5dee\uff0c\u5b9e\u9645\u4e0d\u5927\u53ef\u80fd\u4f7f\u7528\uff1b***\u51b3\u5b9a\u4f7f\u7528BULK INSERT\u8bed\u53e5\u5b9e\u73b0\u3002<\/p>\n<p>BULK INSERT\u4e5f\u53ef\u4ee5\u5b9e\u73b0\u5927\u6570\u636e\u91cf\u7684\u5bfc\u5165\uff0c\u800c\u4e14\u53ef\u4ee5\u901a\u8fc7\u7f16\u7a0b\u5b9e\u73b0\uff0c\u754c\u9762\u53ef\u4ee5\u505a\u7684\u975e\u5e38\u53cb\u597d\uff0c\u5b83\u7684\u901f\u5ea6\u4e5f\u5f88\u9ad8\uff1a\u5bfc\u5165100\u4e07\u6761\u6570\u636e\u4e0d\u523020\u79d2\u4e2d\uff0c\u5728\u901f\u5ea6\u4e0a\u6050\u6015\u65e0\u51fa\u5176\u53f3\u8005\u3002<\/p>\n<p>\u4f46\u662f\u4f7f\u7528\u8fd9\u79cd\u65b9\u5f0f\u4e5f\u6709\u5b83\u7684\u51e0\u4e2a\u7f3a\u70b9\uff1a<\/p>\n<p>1.\u9700\u8981\u72ec\u5360\u63a5\u53d7\u6570\u636e\u7684\u8868<\/p>\n<p>2.\u4f1a\u4ea7\u751f\u5927\u91cf\u7684\u65e5\u5fd7<\/p>\n<p>3.\u4ece\u4e2d\u53d6\u6570\u636e\u7684\u6587\u4ef6\u6709\u683c\u5f0f\u9650\u5236<\/p>\n<p>\u4f46\u76f8\u5bf9\u4e8e\u5b83\u7684\u901f\u5ea6\u6765\u8bf4\uff0c\u8fd9\u4e9b\u7f3a\u70b9\u90fd\u662f\u53ef\u4ee5\u514b\u670d\u7684\uff0c\u800c\u4e14\u4f60\u5982\u679c\u613f\u610f\u727a\u7272\u4e00\u70b9\u901f\u5ea6\u7684\u8bdd\uff0c\u8fd8\u53ef\u4ee5\u505a\u66f4\u7cbe\u786e\u7684\u63a7\u5236\uff0c\u751a\u81f3\u53ef\u4ee5\u63a7\u5236\u6bcf\u4e00\u884c\u7684\u63d2\u5165\u3002<\/p>\n<p>\u5bf9\u4e0e\u4ea7\u751f\u5360\u7528\u5927\u91cf\u7a7a\u95f4\u7684\u65e5\u5fd7\u7684\u60c5\u51b5\uff0c\u6211\u4eec\u53ef\u4ee5\u91c7\u53d6\u5728\u5bfc\u5165\u524d\u52a8\u6001\u66f4\u6539\u6570\u636e\u5e93\u7684\u65e5\u5fd7\u65b9\u5f0f\u4e3a\u5927\u5bb9\u91cf\u65e5\u5fd7\u8bb0\u5f55\u6062\u590d\u6a21\u5f0f\uff0c\u8fd9\u6837\u5c31\u4e0d\u4f1a\u8bb0\u5f55\u65e5\u5fd7\u4e86\uff0c\u5bfc\u5165\u7ed3\u675f\u540e\u518d\u6062\u590d\u539f\u6765\u7684\u6570\u636e\u5e93\u65e5\u5fd7\u8bb0\u5f55\u65b9\u5f0f\u3002<\/p>\n<p>\u5177\u4f53\u7684\u4e00\u4e2a\u8bed\u53e5\u6211\u4eec\u53ef\u4ee5\u8fd9\u6837\u5199\uff1a<\/p>\n<p>&nbsp;<\/p>\n<pre>\n \n \n <ol>\n  \n  \n  <li><span><span>alter&nbsp;database&nbsp;taxi &nbsp;<\/span><\/span><\/li>\n  \n  \n  <li><span>set&nbsp;RECOVERY&nbsp;BULK_LOGGED &nbsp;<\/span><\/li>\n  \n  \n  <li><span>BULK&nbsp;INSERT&nbsp;taxi..detail&nbsp;FROM&nbsp;'e:\\out.txt' &nbsp;<\/span><\/li>\n  \n  \n  <li><span>WITH&nbsp;( &nbsp;<\/span><\/li>\n  \n  \n  <li><span>??&nbsp;<\/span><span>DATAFILETYPE<\/span><span>&nbsp;=&nbsp;<\/span><span>'char'<\/span><span>, &nbsp;<\/span><\/li>\n  \n  \n  <li><span>??&nbsp;<\/span><span>FIELDTERMINATOR<\/span><span>&nbsp;=&nbsp;<\/span><span>','<\/span><span>, &nbsp;<\/span><\/li>\n  \n  \n  <li><span>??&nbsp;<\/span><span>ROWTERMINATOR<\/span><span>&nbsp;=&nbsp;<\/span><span>'\\n'<\/span><span>, &nbsp;<\/span><\/li>\n  \n  \n  <li><span>?TABLOCK &nbsp;<\/span><\/li>\n  \n  \n  <li><span>) &nbsp;<\/span><\/li>\n  \n  \n  <li><span>alter&nbsp;database&nbsp;taxi &nbsp;<\/span><\/li>\n  \n  \n  <li><span>set&nbsp;RECOVERY&nbsp;FULL &nbsp;<\/span><\/li>\n \n \n <\/ol><\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u8fd9\u4e2a\u8bed\u53e5\u5c06\u4ecee:\\out.txt\u5bfc\u51fa\u6570\u636e\u6587\u4ef6\u5230\u6570\u636e\u5e93taxi\u7684detail\u8868\u4e2d\u3002<br \/> &nbsp;<\/p>\n<p>\u4ee5\u4e0a\u7684\u76f8\u5173\u5185\u5bb9\u5c31\u662f\u5bf9\u8bb2\u89e3SQL Server\u6d77\u91cf\u6570\u636e\u5bfc\u5165\u7684\u6700\u5feb\u65b9\u6cd5\u7684\u4ecb\u7ecd\uff0c\u671b\u4f60\u80fd\u6709\u6240\u6536\u83b7\u3002<\/p>\n<p>\u3010\u7f16\u8f91\u63a8\u8350\u3011<\/p>\n<ol>\n<li>SQL Server\u6570\u636e\u6574\u7406\u7684\u64cd\u4f5c\u65b9\u6848\u63cf\u8ff0<\/li>\n<li>SQL Server \u6613\u6df7\u6dc6\u7684\u4e00\u4e9b\u6570\u636e\u7c7b\u578b\u6709\u54ea\u4e9b\uff1f<\/li>\n<li>SQL Server \u65e5\u671f\u64cd\u4f5c\u5168\u63a5\u89e6\uff0c\u563b\u563b<\/li>\n<li>\u5bf9SQL Server 2005 BI\u7684\u63cf\u8ff0<\/li>\n<li>SQL server DateDiff \u51fd\u6570\u8bed\u6cd5\u4e2d\u7684\u547d\u540d\u53c2\u6570<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u4e0b\u7684\u6587\u7ae0\u4e3b\u8981\u5411\u5927\u5bb6\u8bb2\u89e3\u7684\u662fSQL Server\u6d77\u91cf\u6570\u636e\u5bfc\u5165\u7684\u6700\u5feb***\u7528\u7684\u5b9e\u9645\u64cd\u4f5c\u65b9\u6cd5\uff0c\u5728\u5b9e\u9645\u64cd\u4f5c\u4e2d\u5c3c\u662f\u5426\u9047 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7038],"tags":[],"class_list":["post-317396","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/317396","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=317396"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/317396\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=317396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=317396"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=317396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}