bcp failing for some DBCS characters

  • Hi,

    This is my table schema

    CREATE TABLE user_table1(

    id int not null,

    user_name nvarchar(256) null

    )

    I am running bcp to insert a text file containing UTF8 data into this table.

    Here is the sample text file:

    1`???_?s????s

    2`?_?s???s

    3`l?_?s?ll?s

    The bcp commad is as follows:

    bcp user_table1 in data.txt -S servername -U username -P password -c -t` -C 65001

    Line 1 fails with the following mesage

    SQLState = 22018, NativeError =0

    Error =[Microsoft][SQL Native Client]Invalid character value for cast specification

    SQLState =HY000,NativeError=0

    Error=[Microsoft][SQL Native Client]Unexpected EOF encountered in BCP data-file

    Lines 2 and 3 are inserted into the table fine.

    My questions:

    1) Are there any know issues with bcp handling UTF8 data on SQL 2005?

    2) Is there a workaround?

  • The bcp commad is as follows:

    bcp user_table1 in data.txt -S servername -U username -P password -c -t` -C 65001

    if use -w while creating txt and as well dumping the text file in to sql server.

    1. while creating text file

    BCP "select top 10000 * from " queryout c:\sample.csv -w -c -S server name -T

    2. while dumping text file in sql server

    BCP in c:\sample.csv -w -c -S servername -T

    This will surely works 🙂

    Thanks,

    Sivakumar R

  • Following Switch combination work for me.

    -T -N -C 437

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply