Adding Rows Using Bulk Copy Operations

Accessing and Changing Relational Data

Accessing and Changing Relational Data

Adding Rows Using Bulk Copy Operations

The Microsoft® SQL Server™ bulk copy components support:

  • Inserting numbers of rows into a table or view.

  • Retrieving large numbers of rows from a table, view, or query.

Bulk copy is the fastest way to add large numbers of rows in SQL Server. There are three ways to run bulk copy operations:

  • Use the bulk copy program (the bcp utility).

    bcp is a command prompt utility. bcp provides for running bulk copies in .bat and .cmd scripts. bcp is used to bulk copy large files into tables or views in SQL Server databases.

  • Use the BULK INSERT statement in Transact-SQL batches, stored procedures, and triggers to bulk copy data from a file into a table or view in a SQL Server database.

    The BULK INSERT statement is executed on the server in the context of the MSSQLServer service, not on the client. If the file being bulk copied is also on the server the data is not moved across the network at all. This makes a BULK INSERT from a file on the server the fastest bulk copy option. For more information, see BULK INSERT.

  • Use the bulk copy APIs for OLE DB, ODBC, and DB-Library applications.

    The bcp utility is an ODBC command prompt utility that uses the SQL Server ODBC driver bulk copy functions. Any application can use these published bulk copy functions in ODBC or DB-Library applications to run bulk copy operations. Applications can bulk copy from files into a SQL Server table or view. Applications can also bulk copy from program variables into a SQL Server table or view. For more information about OLE DB bulk copies, see Bulk-Copy Rowsets. For more information about ODBC bulk copies, see Performing Bulk Copy Operations. For more information about DB-Library bulk copies, see Bulk-Copy Functions.

To add data using the bcp utility

Client Utility