{"id":3220,"date":"2022-04-12T07:56:12","date_gmt":"2022-04-12T00:56:12","guid":{"rendered":"https:\/\/www.sqlservertutorial.net\/?page_id=3220"},"modified":"2022-04-12T08:21:19","modified_gmt":"2022-04-12T01:21:19","slug":"sql-server-bcp","status":"publish","type":"page","link":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-bcp\/","title":{"rendered":"SQL Server BCP"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn how to use the SQL Server BCP utility to bulk copy data between an SQL Server instance and a file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='introduction-to-the-sql-server-bcp-utility'>Introduction to the SQL Server BCP utility <a href=\"#introduction-to-the-sql-server-bcp-utility\" class=\"anchor\" id=\"introduction-to-the-sql-server-bcp-utility\" title=\"Anchor for Introduction to the SQL Server BCP utility\">#<\/a><\/h2>\n\n\n\n<p>BCP stands for <strong>B<\/strong>ulk <strong>C<\/strong>opy <strong>P<\/strong>rogram. BCP is a command-line tool that uses the bulk copy program API that allows you to bulk-copy data between an SQL Server instance and a file.<\/p>\n\n\n\n<p>In generally, BCP allows you to:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Bulk export data from a table into a data file<\/li><li>Bulk export data from a query into a data file<\/li><li>Bulk import data from a data file into a table<\/li><li>Generate format files<\/li><\/ul>\n\n\n\n<p>To launch the BCP program, you open the command line and use the <code>bcp<\/code> command.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">bcp<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The following command shows the version of the <code>bcp<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">bcp -v<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this command, the <code>-v<\/code> stands for version<\/p>\n\n\n\n<p>To view all the options of <code>bcp<\/code>, you use the following command:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">bcp ?<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">usage: bcp {dbtable | query} {in | out | queryout | format} datafile\r\n  &#91;-m maxerrors]            &#91;-f formatfile]          &#91;-e errfile]\r\n  &#91;-F firstrow]             &#91;-L lastrow]             &#91;-b batchsize]\r\n  &#91;-n native type]          &#91;-c character type]      &#91;-w wide character type]\r\n  &#91;-N keep non-text native] &#91;-V file format version] &#91;-q quoted identifier]\r\n  &#91;-C code page specifier]  &#91;-t field terminator]    &#91;-r row terminator]\r\n  &#91;-i inputfile]            &#91;-o outfile]             &#91;-a packetsize]\r\n  &#91;-S server name]          &#91;-U username]            &#91;-P password]\r\n  &#91;-T trusted connection]   &#91;-v version]             &#91;-R regional enable]\r\n  &#91;-k keep null values]     &#91;-E keep identity values]&#91;-G Azure Active Directory Authentication]\r\n  &#91;-h \"load hints\"]         &#91;-x generate xml format file]\r\n  &#91;-d database name]        &#91;-K application intent]  &#91;-l login timeout]<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>bcp<\/code> command has many options. And we only cover the most commonly used ones in this tutorial.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='using-sql-server-bcp-to-export-data-from-a-table-to-a-file'>Using SQL Server bcp to export data from a table to a file <a href=\"#using-sql-server-bcp-to-export-data-from-a-table-to-a-file\" class=\"anchor\" id=\"using-sql-server-bcp-to-export-data-from-a-table-to-a-file\" title=\"Anchor for Using SQL Server bcp to export data from a table to a file\">#<\/a><\/h2>\n\n\n\n<p>To export the data from a table to a flat file, you use the following command:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">bcp database_name.schema_name.table_name out \"path_to_file\" -c -U user_name -P password<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this syntax:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>bcp<\/code> is the command<\/li><li><code>database_name.schema_name.table_name<\/code> is the name of the table that you want to export the data<\/li><li><code>\"path_to_file\"<\/code> is the path to the result file.<\/li><li><code>-c<\/code> option uses the character type for the format<\/li><li><code>-U user_name<\/code> specifies the user that connects to the database. This user needs to have the <code>SELECT<\/code> permission on the table that you want to export.<\/li><li><code>-P password<\/code> specifies the password of the user.<\/li><\/ul>\n\n\n\n<p>If you want the <code>bcp<\/code> program to connect to SQL Server with a trusted connection using integrated security, you can use the <code>-T<\/code> option instead of specifying a username and password:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">bcp<\/span> <span class=\"hljs-selector-tag\">database_name<\/span><span class=\"hljs-selector-class\">.schema_name<\/span><span class=\"hljs-selector-class\">.table_name<\/span> <span class=\"hljs-selector-tag\">out<\/span> \"<span class=\"hljs-selector-tag\">path_to_file<\/span>\" <span class=\"hljs-selector-tag\">-c<\/span> <span class=\"hljs-selector-tag\">-T<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>For example, the following command exports the data of the <code>products<\/code> table from the <code>production<\/code> schema of the <code>bikestores<\/code> <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-sample-database\/\">sample database<\/a> into a file <code>d:\\data\\products.txt<\/code> :<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">bcp kikestores.production.products out \"d:\\data\\products.txt\" -c -U &#91;username] -P &#91;password]<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">Starting copy...\r\n\r\n321 rows copied.\r\nNetwork packet size (bytes): 4096\r\nClock Time (ms.) Total     : 15     Average : (21400.00 rows per sec.)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>It&#8217;s important to note that you need to have the <code>data<\/code> folder on the <code>D:<\/code> drive for the command to run successfully.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='using-sql-server-bcp-to-export-the-result-of-a-query-to-a-file'>Using SQL Server bcp to export the result of a query to a file <a href=\"#using-sql-server-bcp-to-export-the-result-of-a-query-to-a-file\" class=\"anchor\" id=\"using-sql-server-bcp-to-export-the-result-of-a-query-to-a-file\" title=\"Anchor for Using SQL Server bcp to export the result of a query to a file\">#<\/a><\/h2>\n\n\n\n<p>To export the result set of a query to a file, you use the following command:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">bcp \"query\" queryout \"path_to_file\" -w -U &#91;username] -P &#91;password]<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this command, you specify the query inside double quotes followed by the <code>bcp<\/code> and use the <code>queryout<\/code> option.<\/p>\n\n\n\n<p>For example, the following command exports data from a query that selects the product name and list price from the <code>production.products<\/code> table into a file:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">bcp \"select product_name, list_price from bikestores.production.products where model_year=2017\" queryout \"d:\\data\\products.txt\" -w -U sa -P Abcd1234<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">Starting copy...\r\n\r\n85 rows copied.\r\nNetwork packet size (bytes): 4096\r\nClock Time (ms.) Total     : 16     Average : (5312.50 rows per sec.)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='using-sql-server-bcp-to-import-data-into-a-table-from-a-file'>Using SQL Server bcp to import data into a table from a file <a href=\"#using-sql-server-bcp-to-import-data-into-a-table-from-a-file\" class=\"anchor\" id=\"using-sql-server-bcp-to-import-data-into-a-table-from-a-file\" title=\"Anchor for Using SQL Server bcp to import data into a table from a file\">#<\/a><\/h2>\n\n\n\n<p>First, create a new <code>HR<\/code> database with a <code>people<\/code> table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">DATABASE<\/span> hr;\r\nGO\r\n\r\n<span class=\"hljs-keyword\">USE<\/span> hr;\r\n\r\n<span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> people (\r\n  <span class=\"hljs-keyword\">id<\/span> <span class=\"hljs-built_in\">int<\/span> <span class=\"hljs-keyword\">IDENTITY<\/span> PRIMARY <span class=\"hljs-keyword\">KEY<\/span>,\r\n  first_name <span class=\"hljs-built_in\">varchar<\/span>(<span class=\"hljs-number\">50<\/span>) <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-literal\">NULL<\/span>,\r\n  last_name <span class=\"hljs-built_in\">varchar<\/span>(<span class=\"hljs-number\">50<\/span>) <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-literal\">NULL<\/span>\r\n);\r\n\r\n<span class=\"hljs-keyword\">INSERT<\/span> <span class=\"hljs-keyword\">INTO<\/span> people (first_name, last_name)\r\n  <span class=\"hljs-keyword\">VALUES<\/span> (<span class=\"hljs-string\">'John'<\/span>, <span class=\"hljs-string\">'Doe'<\/span>), (<span class=\"hljs-string\">'Jane'<\/span>, <span class=\"hljs-string\">'Doe'<\/span>);\r\n\r\n<span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> people;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, export the data from the <code>people<\/code> table to a file:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">bcp hr.dbo.people OUT d:\\data\\people.bcp -T -c<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">Starting copy...\r\n\r\n2 rows copied.\r\nNetwork packet size (bytes): 4096\r\nClock Time (ms.) Total     : 1      Average : (2000.00 rows per sec.)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Third, <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-truncate-table\/\">truncate<\/a> the <code>people<\/code> table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-15\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">TRUNCATE<\/span> <span class=\"hljs-keyword\">TABLE<\/span> people;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-15\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>After that, import data from the <code>d:\\data\\people.bcp<\/code> into the <code>people<\/code> table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-16\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">bcp hr.dbo.people IN d:\\data\\people.bcp -T -c<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-16\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-17\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">Starting copy...\r\n\r\n2 rows copied.\r\nNetwork packet size (bytes): 4096\r\nClock Time (ms.) Total     : 16     Average : (125.00 rows per sec.)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-17\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Finally, verify the import by <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-select\/\">selecting<\/a> data from the <code>people<\/code> table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-18\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> people;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-18\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"239\" height=\"77\" src=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/sql-server-bcp-example.png\" alt=\"\" class=\"wp-image-3224\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>SQL Server BCP is a Bulk Copy Program that allows you to bulk-copy data between an SQL Server instance and a data file using a specified file format.<\/li><\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"3220\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-bcp\/\"\n\t\t\t\tdata-post-title=\"SQL Server BCP\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"3220\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-bcp\/\"\n\t\t\t\tdata-post-title=\"SQL Server BCP\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you&#8217;ll learn how to use the SQL Server BCP utility to bulk copy data between an SQL Server instance and a file.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":2903,"menu_order":25,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-3220","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SQL Server BCP<\/title>\n<meta name=\"description\" content=\"In this tutorial, you&#039;ll learn how to use the SQL Server BCP utility to bulk copy data between an SQL Server instance and a file.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-bcp\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Server BCP\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you&#039;ll learn how to use the SQL Server BCP utility to bulk copy data between an SQL Server instance and a file.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-bcp\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Server Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2022-04-12T01:21:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/sql-server-bcp-example.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-bcp\\\/\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-bcp\\\/\",\"name\":\"SQL Server BCP\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-bcp\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-bcp\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/sql-server-bcp-example.png\",\"datePublished\":\"2022-04-12T00:56:12+00:00\",\"dateModified\":\"2022-04-12T01:21:19+00:00\",\"description\":\"In this tutorial, you'll learn how to use the SQL Server BCP utility to bulk copy data between an SQL Server instance and a file.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-bcp\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-bcp\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-bcp\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/sql-server-bcp-example.png\",\"contentUrl\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/sql-server-bcp-example.png\",\"width\":239,\"height\":77},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-bcp\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Server Administration\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"SQL Server BCP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\",\"name\":\"SQL Server Tutorial\",\"description\":\"The Practical SQL Server Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SQL Server BCP","description":"In this tutorial, you'll learn how to use the SQL Server BCP utility to bulk copy data between an SQL Server instance and a file.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-bcp\/","og_locale":"en_US","og_type":"article","og_title":"SQL Server BCP","og_description":"In this tutorial, you'll learn how to use the SQL Server BCP utility to bulk copy data between an SQL Server instance and a file.","og_url":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-bcp\/","og_site_name":"SQL Server Tutorial","article_modified_time":"2022-04-12T01:21:19+00:00","og_image":[{"url":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/sql-server-bcp-example.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-bcp\/","url":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-bcp\/","name":"SQL Server BCP","isPartOf":{"@id":"https:\/\/www.sqlservertutorial.net\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-bcp\/#primaryimage"},"image":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-bcp\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/sql-server-bcp-example.png","datePublished":"2022-04-12T00:56:12+00:00","dateModified":"2022-04-12T01:21:19+00:00","description":"In this tutorial, you'll learn how to use the SQL Server BCP utility to bulk copy data between an SQL Server instance and a file.","breadcrumb":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-bcp\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-bcp\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-bcp\/#primaryimage","url":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/sql-server-bcp-example.png","contentUrl":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/sql-server-bcp-example.png","width":239,"height":77},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-bcp\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlservertutorial.net\/"},{"@type":"ListItem","position":2,"name":"SQL Server Administration","item":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/"},{"@type":"ListItem","position":3,"name":"SQL Server BCP"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlservertutorial.net\/#website","url":"https:\/\/www.sqlservertutorial.net\/","name":"SQL Server Tutorial","description":"The Practical SQL Server Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlservertutorial.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/3220","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/comments?post=3220"}],"version-history":[{"count":4,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/3220\/revisions"}],"predecessor-version":[{"id":3226,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/3220\/revisions\/3226"}],"up":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/2903"}],"wp:attachment":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/media?parent=3220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}