PRSQL9202002: BCP: Nulls Inserted in Non-Null varchar Column

ID Number: Q80636

1.11

OS/2

buglist1.11

Summary:

Problem ID: PRSQL9202002

SYMPTOMS

When you attempt to use the Bulk Copy Program (BCP) to copy in data

using DB-LIBRARY (dblib) BCP calls for a table containing a varchar

column defined as not allowing null, nulls are inserted into the

table if the field terminator used is anything but "\r\n". This

happens when two consecutive field terminators are encountered,

indicating absence of data, even though the column in the table

does not allow nulls.

WORKAROUND

One workaround is to use the versions 1.x BCP utility. Also, if

"\r\n" is used as the field terminator for the varchar field, the

above problem is not encountered.

STATUS

Microsoft has confirmed this to be a problem in SQL Server version

1.11. This problem does not occur in SQL Server version 4.2.

More Information:

Example

-------

Suppose you have the following

create table (c1 varchar(5))

and you use the following

bcp_colfmt(dbproc,1, SQLCHAR,0,5,"\t",1,1)

followed by:

bcp_exec(dbproc,&rownum)

Then, if the operating system file resembles the following

abc\t\t

after BCP, the table resembles the following:

c1

-----

abc

NULL

Additional reference words: 1.11 db-lib