The bcp utility is available in the Microsoft SQL Server ODBC Driver for Linux.
The field terminator is a tab ("\t").
The line terminator is a newline ("\n").
Character mode is the preferred format for bcp format files and data files that do not contain extended characters.
Note |
---|
A backslash '\' on a Linux command line argument must either be quoted or escaped. For example to specify a newline as a custom row terminator you must use one of the following mechanisms: |
The following is a sample command invocation of bcp.exe to copy table rows to a text file:
| Copy Code |
---|
bcp AdventureWorks2008R2.Person.Address out test.dat -Usa -Pxxxx -Sxxx.xxx.xxx.xxx |
bcp Options That are Available
In the current release, the following bcp syntax and options are available:
[database.]schema.table in data_file | out data_file
- -a packet_size
Specifies the number of bytes, per network packet, sent to and from the server.
- -b batch_size
Specifies the number of rows per batch of imported data.
- -c
Performs the operation using a character data type.
- -d database_name
Specifies the database to connect to.
- -D
Causes the value passed to the sqlcmd -S option to be interpreted as a data source name (DSN). For more information, see "DSN Support in sqlcmd and bcp" in Connecting with sqlcmd.
- -e eror_file
Specifies the full path of an error file used to store any rows that the bcp utility cannot transfer from the file to the database.
- -E
Specifies that identity value or values in the imported data file are to be used for the identity column.
- -f format_file
Specifies the full path of a format file.
- -F first_row
Specifies the number of the first row to export from a table or import from a data file.
- -k
Specifies that empty columns should retain a null value during the operation, rather than have any default values for the columns inserted.
- -L last_row
Specifies the number of the last row to export from a table or import from a data file.
- -m max_errors
Specifies the maximum number of syntax errors that can occur before the bcp operation is canceled
- -n
Performs the bulk-copy operation using the native (database) data types of the data.
- -P password
Specifies the password for the login ID.
- -q
Executes the SET QUOTED_IDENTIFIERS ON statement in the connection between the bcp utility and an instance of SQL Server.
- -r row_terminator
Specifies the row terminator.
- -R
Specifies that currency, date, and time data is bulk copied into SQL Server using the regional format defined for the locale setting of the client computer.
- -S server
Specifies the name of the SQL Server instance to connect to. Or, if -D is used, a DSN.
- -t field_terminator
Specifies the field terminator.
- -T
Specifies that the bcp utility connects to SQL Server with a trusted connection using integrated security.
- -U login_id
Specifies the login ID used to connect to SQL Server.
- -v
Reports the bcp utility version number and copyright.
- -w
Performs the bulk copy operation using Unicode characters.
In this release, Latin-1 and UTF-16 characters are supported.
bcp Options That are Not Available
In the current release, the following bcp syntax and options are not available:
- -C
Specifies the code page of the data in the data file.
- -h hint
Specifies the hint or hints to be used during a bulk import of data into a table or view.
- -i input_file
Specifies the name of a response file.
- -N
Performs the bulk-copy operation using the native (database) data types of the data for noncharacter data, and Unicode characters for character data.
- -o output_file
Specifies the name of a file that receives output redirected from the command prompt.
- -V (80 | 90 | 100)
Performs the bulk-copy operation using data types from an earlier version of SQL Server.
- -x
Used with the format and -f format_file options, generates an XML-based format file instead of the default non-XML format file
See Also