bcp changing high ascii values

  • bcp appears to be changing some high ascii values on import (eg 249 to 168). How can I control/prevent this behaviour?

  • Stephen Grimshaw - Monday, December 18, 2017 9:56 AM

    bcp appears to be changing some high ascii values on import (eg 249 to 168). How can I control/prevent this behaviour?

    More information please!
    😎

  • 1. Table
    create table ascii_test(string varchar(15))

    2. input file attached

    3. bcp command
    bcp ascii_test in diuc.txt  -c -T

    4. Here's query on what arrives in the database
    select seq,substring(string,seq,1),ascii(substring(string,seq,1))
    from ascii_test, (select top 12  seq=row_number() over(order by crdate) from sysobjects)  a

    5. Here's the result
    1 D 68
    2 I 73
    3 Β¨ 168
    4 C 67
    5   32
    6 E 69
    7 D 68
    8 W 87
    9 A 65
    10 R 82
    11 D 68
    12 S 83

  • and the server/db/table collation?
    😎
    What does this return?
    SELECT
      char(249) AS FROM_CHAR
     ,char(168) AS TO_CHAR
    ;

  • FROM_CHAR TO_CHAR
    ΓΉ Β¨

  • And the collation?
    😎

  • Thank you for your help on this. 
    Collation is Latin1_General_CI_AS

  • Stephen Grimshaw - Monday, December 18, 2017 10:18 AM

    1. Table
    create table ascii_test(string varchar(15))

    2. input file attached

    3. bcp command
    bcp ascii_test in diuc.txt  -c -T

    4. Here's query on what arrives in the database
    select seq,substring(string,seq,1),ascii(substring(string,seq,1))
    from ascii_test, (select top 12  seq=row_number() over(order by crdate) from sysobjects)  a

    5. Here's the result
    1 D 68
    2 I 73
    3 Â¨ 168
    4 C 67
    5   32
    6 E 69
    7 D 68
    8 W 87
    9 A 65
    10 R 82
    11 D 68
    12 S 83

    ???

  • Lynn Pettis - Monday, December 18, 2017 11:05 AM

    Stephen Grimshaw - Monday, December 18, 2017 10:18 AM

    1. Table
    create table ascii_test(string varchar(15))

    2. input file attached

    3. bcp command
    bcp ascii_test in diuc.txt  -c -T

    4. Here's query on what arrives in the database
    select seq,substring(string,seq,1),ascii(substring(string,seq,1))
    from ascii_test, (select top 12  seq=row_number() over(order by crdate) from sysobjects)  a

    5. Here's the result
    1 D 68
    2 I 73
    3 Â¨ 168
    4 C 67
    5   32
    6 E 69
    7 D 68
    8 W 87
    9 A 65
    10 R 82
    11 D 68
    12 S 83

    ???

    1. Table
    create table ascii_test(string varchar(15))

    2. input file attached

    3. bcp command
    bcp ascii_test in diuc.txt -c -T

    4. Here's query on what arrives in the database
    select seq,substring(string,seq,1),ascii(substring(string,seq,1))
    from ascii_test, (select top 12 seq=row_number() over(order by crdate) from sysobjects) a

    5. Here's the result
    1 D 68
    2 I 73
    3 ¨ 168
    4 C 67
    5 32
    6 E 69
    7 D 68
    8 W 87
    9 A 65
    10 R 82
    11 D 68
    12 S 83

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • Hmmm... what you may want to try is adding the following "switch" to the BCP command...

    -C RAW

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Thank you very much. That seems to do the trick.
    Now that I have the hint where to look I'll read the right documentation!

  • Stephen Grimshaw - Tuesday, December 19, 2017 2:39 AM

    Thank you very much. That seems to do the trick.
    Now that I have the hint where to look I'll read the right documentation!

    Awesome... thank you for the feedback, Stephen.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 12 posts - 1 through 11 (of 11 total)

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