SqlBCPExec%

Executes a bulk-copy of data between a database table and an operating-system file.

Syntax

SqlBCPExec% ( sqlconn%, rowscopied& )

where

sqlconn%
Is a SQL Server connection. The value of sqlconn% is returned by SqlOpen%.
rowscopied&
Is the number of rows successfully copied.

Returns

SUCCEED (1) or FAIL (0). The SqlBCPExec% function returns SUCCEED only when all rows are copied. If some or none of the rows are copied, SqlBCPExec% returns FAIL. Check the rowscopied& parameter for the number of rows successfully copied.

Remarks

SqlBCPExec% copies data from an operating-system file to a database table or vice versa, depending on the value of the direction% parameter in SqlBCPInit%.

Before calling SqlBCPExec%, you must call SqlBCPInit% with a valid operating-system filename. Failure to do so results in an error.

Example

'Initialize bcp.
Result% = 
SqlBCPInit%(Sqlconn%,"pubs..authors", "authors.sav", "", DBOUT%)
IF Result% = FAIL THEN
   SQLExit
   SQLWinExit
   End
END IF

'Now, execute the bulk-copy.
Result% = 
SqlBCPExec%(Sqlconn%, RowsCopied&)
IF Result% = FAIL THEN
   PRINT "Incomplete bulk-copy. Only "; RowsCopied&; " rows copied."
   PRINT
   SQLExit
   SQLWinExit
   End
END IF

See Also

SqlBCPColfmt%, SqlBCPColumns%, SqlBCPControl%, SqlBCPInit%