bcp leaves field terminator at end of line

  • Hi friends,

    With BCP, Using -c -t, to export a table into what I would like to be a .csv file. BCP is leaving a comma (the field separator) at the end of each line before the eol character.

    Does anyone know how to lose this end of field terminator at the end of line?

    Ex;

    400,9590002012,9590002012,Nov 2 2012 12:,Nov 23 2012 12:,2015-02-13 13:44:32.570,<----


    Chip

  • Are you using a format file?

    Could you post the bcp command that you're using (obfuscating paths and filenames)?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • I cannot use a format file as I have varying columns. This was latest effort. I have tried all sorts of combinations.

    BCP.exe "Some DB.SCHEMA.table" Out -c -t, -T "Table.csv" /SCISSQL11\Archives /Usa /PPassword /m10 /e"Table.err" /o"Table.out"

    Thanks


    Chip

  • I'm not sure what you're doing or how you're getting that. Maybe you have an empty column at the end which simulates a trailing comma.

    Using this code, I didn't got the comma.

    BCP.exe "Test.dbo.Table" Out "C:\Table.csv" -c -t"," -SMyTestServer -T -m10 -e"C:\Table.err" -o"C:\Table.out"

    I noticed that you posted slashes instead of dashes and you had the data_file in an incorrect position. I'm using a trusted connection because I have Windows Authentication, but you're including user and password for SQL Server Authentication so that's the only difference which shouldn't affect the file format.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Found it. There is a hidden null at the end of line.

    That leaves me many solutions.

    Thanks for your input. may be back for more..

    :hehe:

    RE: DBA leaves field terminator at end of line


    Chip

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

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