BUG: BCP IN with 4GB or Larger File Fails with Unexpected EOF

ID: Q238455


The information in this article applies to:

BUG #: 56148 (SQLBUG_70)

SYMPTOMS

The SQL Server ODBC Bulk Copy API doing file operations to import data can end with one or more 'Unexpected End Of File(EOF)' errors if the file is 4 GB or larger and contains a NULL value to be imported.

The number of reported failures matches the number of maximum errors allowed for the BCP operation. The default value is 10 but it can be changed using the (-m) parameter of BCP.exe.


CAUSE

When checking to ensure the correct file position is maintained when a NULL is located, only the low-order doubleword of the file size is interrogated by the SQLSRV32.dll driver.

The low-order doubleword of the file size maintains the position within the given 4 GB segment of the file. Thus, if the file is 4 GB or larger the low-order doubleword is the number of bytes exceeding the boundary. The following four examples illustrate the low-order doubleword calculations.

(Total File Size) - (Closest 4GB boundary) = low-order doubleword


1.  5GB - 4GB = 1GB 
2.  7.5GB - 4GB = 3.5GB
3.  4GB 6 bytes - 4GB = 6 bytes
4.  17GB - 16GB = 1GB (low-order doubleword) and 3 as the high-order doubleword 
The BCP check fails when the position you are currently reading exceeds the low-order doubleword boundary. The first example fails when the first NULL is encountered after importing 1 GB worth of data from the file. The second would be 3.5 and so forth.


RESOLUTION

A supported fix that corrects this problem is now available from Microsoft, but it has not been fully regression tested and should be applied only to systems experiencing this specific problem. If you are not severely affected by this specific problem, Microsoft recommends that you wait for the next SQL Server service pack that contains this fix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information on support costs, please go to the following address on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
The English version of this fix should have the following file attributes or later:


   File name   Platform
   ---------------------------------------------------------

   BCPFail.exe  Intel
 
NOTE: Due to file dependencies, the most recent hotfix or feature that contains the above files may also contain additional files.

NOTE: If this product was already installed on your computer when you purchased it from the Original Equipment Manufacturer (OEM) and you need this fix, please call the Pay Per Incident number listed on the above Web site. If you contact Microsoft to obtain this fix, and if it is determined that you only require the fix you requested, no fee will be charged. However, if you request additional technical support, and if your no-charge technical support period has expired, or if you are not eligible for standard no-charge technical support, you may be charged a non-refundable fee.

For more information about eligibility for no-charge technical support, see the following article in the Microsoft Knowledge Base:
Q154871 Determining If You Are Eligible for No-Charge Technical Support


WORKAROUND

Keep the file size under 4 GB in size.

NOTE: Using the BCP.exe option to control the first and last row to import on a file over 4GB in size does NOT avoid the issue. The file must remain smaller than 4GB in size.


STATUS

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


MORE INFORMATION

All files types (native, character, with format file) are affected if a NULL exists that is to be imported.

Additional query words:


Keywords          : kbSQLServ700bug 
Version           : winnt:7.0
Platform          : winnt 
Issue type        : kbbug 

Last Reviewed: August 8, 1999