SqlBCPInit%

Initializes a bulk-copy operation.

Syntax

SqlBCPInit% ( sqlconn%, tblname$, hfile$, errfile$, direction% )

where

sqlconn%
Is a SQL Server connection. The value of sqlconn% is returned by SqlOpen%.
tblname$
Is the name of the database table to copy. This name can also include the name of the database and the name of the database owner. For example, pubs.gracie.titles, pubs..titles, gracie.titles, and titles are all legal table names.

If direction% is DBOUT%, tblname$ can also be the name of a database view.

hfile$
Is the name of the operating-system file to bulk copy into or out of SQL Server.
errfile$
Is the name of the error file to be used. This error file contains progress messages, error messages, and copies of any rows that could not be copied from an operating-system file to a SQL Server table. If NULL is passed as errfile$, no error file is used.
direction%
Is the direction of the copy. This parameter must be one of two values: DBIN% or DBOUT%. DBIN% indicates a copy from an operating-system file into the database table; DBOUT% indicates a copy from a database table into an operating-system file.

Returns

SUCCEED (1) or FAIL (0).

Remarks

SqlBCPInit% performs the initializations necessary to bulk-copy data between a workstation and SQL Server. It sets the default data formats for the operating-system file and examines the structure of the database table.

When you use an operating-system file to bulk-copy (see the description of the hfile$ parameter), the default native data formats are as follows:

You can override any of these defaults by calling SqlBCPColumns% and SqlBCPColfmt%.

To use the bulk-copy functions to copy data to a database table, you must do the following:

The SqlBCPInit% function must be called before any other bulk-copy functions. Failure to do so results in an error.

See Also

SqlBCPColfmt%, SqlBCPColumns%, SqlBCPControl%, SqlBCPExec%, SqlBCPSetL%