bcp out in ansi format

  • Hi, i am tring to export txt file with ansi encoding instead of unicode but always go out with unicode.

    i use :

    set @cmd='bcp "cnet.dbo.[actu]" out "'+@path+'\file.txt" -w -S "SERVsql2" -T'

    exec master..xp_cmdShell @cmd

    any help plz?

  • Try adding the -c parameter.  If that doesn't do it for you, add the -C parameter with the proper code page (see Books Online for the proper code page.)  Do notice the parameters are case sensitive.

    --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)

  • In actuality you are not creating a unicode text file. By not specifying th -c (character mode) parameter your bcp out file is in the default 'native' format.

    RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."

  • I tried to use the -C parameter but I didn't find a code page that works fine with ascent words.

     

    Anyone knows anyway to use the -C parameter?

  • I've not had to work with Accent words so I'm not 100% sure... if I remember correctly, though, take a look at "Collation" in Books Online... seems like I remember getting to some code page info that way...

    --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)

  • I usually use the -C parameter when I need to convert chars between ANSI -> OEM or OEM -> ANSI in any of the directions file -> table or table -> file.

    If one doesn't do the trick, then the other will. Just try which one is right. It will depend on stuff like db collation, tool used, middle layer settings etc, so I've never bothered to much with it, just picked the one that would make it right for the particular job.

    The two I use are:

    -C ACP

    -C OEM

    /Kenneth

Viewing 6 posts - 1 through 5 (of 5 total)

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