February 25, 2015 at 3:25 pm
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
February 25, 2015 at 4:17 pm
Are you using a format file?
Could you post the bcp command that you're using (obfuscating paths and filenames)?
February 25, 2015 at 5:23 pm
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
February 25, 2015 at 6:30 pm
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.
February 27, 2015 at 11:54 am
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