BCP is a command-line tool in SQL Server that is responsible for importing exported data, is based on db-library, and can efficiently import and export large quantities of data in a parallel manner. This article describes how to import export data using bcp.
BCP is a command-line tool in SQL Server that is responsible for importing exported data, is based on db-library, and can efficiently import and export large quantities of data in a parallel manner. BCP can export a table or view of a database directly, or it can filter the table or view through a select from statement. When you import export data, you can use default values or use a format file to import data from a file into a database or to export data from a database to a file.
The following is a detailed discussion of how to import export data using bcp.
1. Introduction to main parameters of BCP
BCP has a total of four actions to choose from.
(1) Import.
This action is done using the in command followed by the name of the file you want to import.
(2) export.
This action is done using the Out command followed by the name of the file you want to export.
(3) Export using SQL statements.
This action is done using the Queryout command, which is similar to out, except that the data source is not a table or view name, but rather an SQL statement.
(4) Export the format file.
This action is done using the Format command, followed by the file name.
The following are some common options:
-F Format_file
Format_file represents the format file name. This option depends on the action described above, if you are using in or Out,format_file to indicate a format file that already exists, and if you are using format, it means the file you want to generate.
-X
This option is used in conjunction with-F format_file to generate XML-formatted format files.
-F First_row
Specifies which row from the exported table is exported, or from which line of the file being imported.
-L Last_row
Specifies which line to end when the exported table is to be directed to, or from the file being imported.
-C