Command-line utilities are executable programs run from a command prompt. The bulk copy program (bcp) is a command-line utility that copies SQL Server data to or from an operating-system file in a user-specified format. Because the bcp utility can be used to copy data in different ways, read this entire chapter before using bcp to copy information.
The following topics discuss using the bcp utility interactively as well as automatically, with the frequently used defaults. They discuss how you should copy a table that has indexes, and what happens to tables with triggers, rules, and defaults. Finally, they give several examples and scenarios showing the different ways you can use the bcp utility.
The bcp utility is most frequently used to transfer data into a SQL Server database from another program, usually another database management system. The data to be transferred must be put into an operating-system file or onto a diskette with a backup facility provided by the old program.
The bcp utility is also used for temporary transfers of data for use with other programsū for example, with spreadsheet programs. The data is moved from SQL Server into an operating-system file or onto a diskette; from there, the other program can import the data.
SQL Server can accept data in any ASCII or binary format as long as the terminators (the characters used to separate columns and rows) can be described. The table structures need not be identical. Data copied into SQL Server is appended to any existing contents of a table; data copied to a file overwrites any previous contents of the file.
To use bcp, a user must have a SQL Server login account and the appropriate permissions on the database tables, views, and operating-system files.
For more information choose one of the following topics:
Permissions Needed to Copy Data
Using Native and Character Format bcp
Copying Tables With or Without Indexes
Copying Tables with Defaults, Rules, and/or Triggers
Copying In or Out of a Temporary Table