The ODBC bulk copy sample illustrates using Microsoft® SQL Server™ bulk copy functions with the SQL Server ODBC driver.
To build the application, you must ensure that 3.x versions of the ODBC header files and libraries are used, that the SQL Server version 7.0 version of Odbcss.h is used, and that the linker can find Odbcbcp.lib.
The sample is a Microsoft Foundation Class dialog application. The application allows you to connect to a defined ODBC SQL Server datasource and requires that you enter the name of a command file to process.
Command files allow you to tailor command processing by the application. The application recognizes two commands: ScriptRun, which processes Transact-SQL statements; and BCPData, which performs a bulk copy operation. The application treats strings enclosed in brackets ([]) as progress text and displays them in its progress panel area as the application processes a command file.
Sample data, containing a command file, script file, and character format bcp data files for the Northwind sample database are included.
[text]
ScriptRun "file_name"
BCPData "database..table", "file_name", "errorfile", direction
To run the ODBC bulk copy sample:
C:\Mssql17\Devtools\Samples\ODBC\Data\Northbcp
cd C:\Mssql17\Devtools\Samples\ODBC\Data\Northbcp
Bcpsamp
Bcp.mak contains nmake configurations for ANSI and Unicode debug and release versions of the sample.
Build target | CFG parameter | Output directory |
---|---|---|
ANSI debug | “BCP - Win32 Debug” | Debug |
ANSI release | “BCP - Win32 Release” | Release |
Unicode debug | “BCP - Win32 Unicode Debug” | Debug |
Unicode release | “BCP - Win32 Unicode Release” | Release |
bcp_control | SQLDisconnect | SQLNumResultCols |
bcp_exec | SQLDriverConnect | SQLPrepare |
bcp_init | SQLExecDirect | SQLSetConnectAttr |
SQLAllocHandle | SQLFreeHandle | SQLSetEnvAttr |
SQLColAttribute | SQLGetDiagField | |
SQLDataSources | SQLGetDiagRec |