bcp_readfmt

Reads a datafile format definition from a user file for a bulk copy between a file and SQL Server.

Syntax

RETCODE bcp_readfmt (
PDBPROCESS
dbproc,
LPCSTR
filename );

where

dbproc
Is the DBPROCESS structure that is the handle for a particular workstation/ SQL Server process. It contains all the information that DB-Library uses to manage communications and data between the workstation and SQL Server.
filename
Is the full directory and file name specification of the file containing the format definitions.

Returns

SUCCEED or FAIL.

Remarks

After bcp_readfmt reads a datafile format definition from a host file, it makes the appropriate calls to bcp_columns and bcp_colfmt. These calls automate the bulk copy of multiple files that share a common data format.

The bulk copy utility (bcp) copies a database table to or from a host file in a user-specified format, which can be saved with bcp in definition files for datafile format. These files can later automate the process of bulk copying files that share a common format. For more information on the bcp utility and definition files for datafile format, see the Microsoft SQL Server Transact-SQL Reference.

Applications can call bcp_writefmt to create files that define datafile formats.

Note The format file cannot have been produced by a version of the bcp utility program earlier than version 4.2.

The following code fragment shows how to use bcp_readfmt:

bcp_init(dbproc, "mytable", "bcpdata", "bcperrs", DB_IN);

bcp_readfmt(dbproc, "my_fmtfile");

bcp_exec(dbproc, &rows_copied);

See Also

bcp_colfmt, bcp_columns, bcp_writefmt