BUG: BCP May Export Corrupted DBCS Characters That Are Stored In a Char or Varchar Data Type (323502)



The information in this article applies to:

  • Microsoft SQL Server 2000 (all editions)

This article was previously published under Q323502
BUG #: 356458 (SHILOH_BUGS)
BUG #: 85675 (MDAC_BUGS)

SYMPTOMS

Double-byte character set (DBCS) characters that are exported by the bcp utility, may contain corrupted data if all of the following conditions are true:
  • The exported column's data type is char or varchar.
  • The DBCS data stored in the exported column has 1022 bytes, or more, in size.
  • The -c switch is used. For example:
    bcp "pubs..test" out out.txt -S. -T -c
    						

WORKAROUND

To work around this problem, use one of the following methods:
  • Use the -w switch instead of the -c switch when you run the bcp utility. For example:
    bcp pubs..test out out.txt -S. -T -w
    					
    -or-

  • Use the nchar or the nvarchar data type instead of a char or a varchar data type for the DBCS columns. -or-

  • Use the SQL Server 7.0 bcp client.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

Follow these steps to reproduce the behavior:
  1. Create a new table with a char or a varchar column:
    use pubs
    go
    create table test (col1 varchar(5000))
    go
    					
  2. Insert 1024 DBCS characters (2048 bytes) into the table you created in step 1:
    insert test values(replicate(0x8260, 1024))
    go
    					
  3. Run the following bcp command at the command prompt:
    bcp pubs..test out out.txt -S. -T -c
    					
RESULT: Instead of seeing exactly 1024 characters of 0x8260, some of the characters are corrupted.

Modification Type:MajorLast Reviewed:10/3/2003
Keywords:kbBug kbpending KB323502