Reads a data file format definition from a user file for a bulk copy between a file and Microsoft® SQL Server™.
RETCODE bcp_readfmt (
PDBPROCESS dbproc,
LPCSTR file_name );
SUCCEED or FAIL.
After bcp_readfmt reads a data file 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 about the bcp utility and definition files for datafile format, see Transact-SQL Reference.
Applications can call bcp_writefmt to create files that define data file 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);
bcp_colfmt | bcp_writefmt |
bcp_columns |