BCP Export/Import problem.

BCP Export/Import problem.

Post by Craig Hurcu » Sat, 29 Jun 2002 00:15:45



I have a problem with bcp for exporting from a table to a file, then
importing this file into another table.  Both tables are on separate SQL
Server 2000 databases, installed with SP2, and both tables have an identical
structure.

Using bcp from the command line works fine...
bcp DBTEST..ProductMetadata out Product.dat /SP816345NT /n
bcp DBTEST..ProductMetadata in Product.dat /SP816345NT /n

However when running from a C++ application using the following :-

Export function...
bcp_init(dbproc, databasename, filename, errorlog, DB_OUT);
bcp_exec(dbproc, &rowsread);

Import function...
bcp_init(dbproc, databasename, filename, errorlog, DB_IN);
bcp_exec(dbproc, &rowsread);







1 Assigned Priority <Unable to display>

 I cannot import the file created in the Export function using bcp from the
command line either.

Any help would be greatly appreciated,

Regards,
Craig.

 
 
 

BCP Export/Import problem.

Post by lindawi » Sat, 29 Jun 2002 00:11:29


Craig,

> I have a problem with bcp for exporting from a table to a file, then
> importing this file into another table.  Both tables are on separate
> SQL Server 2000 databases, installed with SP2, and both tables have
> an identical structure.

> Using bcp from the command line works fine...
> bcp DBTEST..ProductMetadata out Product.dat /SP816345NT /n
> bcp DBTEST..ProductMetadata in Product.dat /SP816345NT /n

> However when running from a C++ application using the following :-

> Export function...
> bcp_init(dbproc, databasename, filename, errorlog, DB_OUT);
> bcp_exec(dbproc, &rowsread);

> Import function...
> bcp_init(dbproc, databasename, filename, errorlog, DB_IN);
> bcp_exec(dbproc, &rowsread);

> I get the following errors on the import :-


> 1 Assigned Priority <Unable to display>


> 1 Assigned Priority <Unable to display>


> 1 Assigned Priority <Unable to display>

>  I cannot import the file created in the Export function using bcp
> from the command line either.

The error message is telling you what is wrong. Column 3 has the
NOT NULL attribute in the table and you did not supply values.

Either you need to supply values for all columns in the data file
or put default constraints on the columns that can be applied
during the load.

Linda