Generating BCP input file from Perl/Unix -
12-11-2007
, 10:55 AM
Hi,
I am attempting to process a proprietary formatted file into flat csv
for the purpose of bcp'ing into a SQL Server 2005 install. I tried
writing a processor in Perl that "works" except that the BCP tool in
windows just does not like the file, it gives me the "Unexpected
EOF...." error that is usually associated with misaligned fields.
I am pretty sure the cause of this is the end of line character
differences between platforms. I did some tests with a single row
manually inserted and bcp'd out of the SQL Server using csv format,
and the formatting looks identical to my perl output file. When I get
the hex editor involved, I can see the bcp output has 2 characters at
the end of each line (LF and CR if I am correct) whereas the unix
output has only 1.
I have been unable to get the perl script to output the right eol
characters for BCP to work.
I wrote another processor in C# under windows that works perfectly.
Is there a solution in perl? how do I terminate the lines properly? is
there a way to get BCP to recognize and accept different eol
characters?
Any advice is appreciated.
Thanks. |