How to force UNIX line endings with BCP.EXE's -r option
  Home FAQ Contact Sign in
microsoft.public.sqlserver.tools only
 
Advanced search
POPULAR GROUPS

more...

microsoft ... sqlserver.tools Profile…
 Up
How to force UNIX line endings with BCP.EXE's -r option         


Author: Thomas W. Brown
Date: Sep 16, 2008 09:55

I want to export SQL data using BCP.EXE and for normal operation everything's
fine. The default record delimiter of "\n" gets mapped to 0x0D, 0x0A and
this works for the PC/Windows.

But when I want to export data for a UNIX system, I don't know how to tell
BCP to really just spit out a single line feed (0x0A) and not the CR/LF pair.
I can successfully export for Macintosh by using "-r \r" and only a 0x0D is
emitted.

Yes, I can play tricks like emitting just the CR and then running the output
through a tr-like utility to change the 0x0D characters into 0x0A, but it
sure would be nice to bcp out the data with the right record terminators to
begin with!!

Is there a way to tell bcp.exe *not* to cook the line endings and treat \n
as just a linefeed?!?

Regards,
-- TB
2 Comments
Re: How to force UNIX line endings with BCP.EXE's -r option         


Author: Erland Sommarskog
Date: Sep 16, 2008 15:00

Thomas W. Brown (thomas_w_brown@countrywide.NOSPAM.com) writes:
> I want to export SQL data using BCP.EXE and for normal operation
> everything's fine. The default record delimiter of "\n" gets mapped to
> 0x0D, 0x0A and this works for the PC/Windows.
>
> But when I want to export data for a UNIX system, I don't know how to
> tell BCP to really just spit out a single line feed (0x0A) and not the
> CR/LF pair.
> I can successfully export for Macintosh by using "-r \r" and only a 0x0D
> is emitted.
>
> Yes, I can play tricks like emitting just the CR and then running the >
> output through a tr-like utility to change the 0x0D characters into
> 0x0A, but it sure would be nice to bcp out the data with the right
> record terminators to begin with!!
>
> Is there a way to tell bcp.exe *not*...
Show full article (1.25Kb)
no comments
Re: How to force UNIX line endings with BCP.EXE's -r option         


Author: Thomas W. Brown
Date: Sep 16, 2008 15:12

"Erland Sommarskog" wrote:
> Thomas W. Brown (thomas_w_brown@countrywide.NOSPAM.com) writes:
>> I want to export SQL data using BCP.EXE and for normal operation
>> everything's fine. The default record delimiter of "\n" gets...
Show full article (1.11Kb)
no comments