June 14, 2006 at 4:04 am
Hi
I am writing a csv format file with BCP using a basic select from a table. This works 100% but..
I need the file produced by BCP to END with a single EOF marker, while BCP puts in a newline instead - after any EOF marker I add.
Is there some combination of switches that could possibly help me to do this?
Thank you
Howard
June 15, 2006 at 11:19 am
As fare as I know, you can specify a column and/or a row terminator, but not a file terminator. If you can create a file that contains a single EOF (I assume standard ASCII ctrl-z, 0x1A), then after creating your file with bcp, you could append the EOF using:
copy /b bcpfile.txt + eof.txt bcpfilewithEOF.txt
(I used Multi-Edit to create an EOF.txt file)
June 15, 2006 at 11:28 am
You should not have to do something 'special' if the target computer is a Windows based machine. The OS should handle this for you. The only time the OS might not is if your bcp process ends 'abnormally' and does not close the output file properly. Now if the target computer for your bcp file is not WIndows based (Unix, IBM) then the software (ftp, sftp, etc) should be translating the end-of-file markers for you if these tools are configured correctly.
RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."
June 15, 2006 at 12:33 pm
My response was made under the assumption that the application that will use the file as input requires the EOF marker at the end of the file. I agree, Windows API file I/O doesn't require the EOF character.
June 15, 2006 at 12:52 pm
Thank you all for your help!
Addict your response was like Deja Vu...
Late last night I managed in a moment of inspiration, to do exactly as you suggested. I even used the same the eof.txt file name as you. And it works a treat.
BTW: The application I was exporting to is AccPac whose import program seems to need an eof marker almost at the end in the csv file ( it has a few extra ,,, after that!)
Thanks again!
Howard
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply