dbTalk Databases Forums  

How to force UNIX line endings with BCP.EXE's -r option

microsoft.public.sqlserver.tools microsoft.public.sqlserver.tools


Discuss How to force UNIX line endings with BCP.EXE's -r option in the microsoft.public.sqlserver.tools forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Thomas W. Brown
 
Posts: n/a

Default Re: How to force UNIX line endings with BCP.EXE's -r option - 09-16-2008 , 05:12 PM






"Erland Sommarskog" wrote:

Quote:
Thomas W. Brown (thomas_w_brown (AT) countrywide (DOT) 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* to cook the line endings and treat \n
as just a linefeed?!?

You need to use a format file. In a format file \n means \n and not \r\n.

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se
Excellent, thanks!!

-- TB



Reply With Quote
  #12  
Old   
Thomas W. Brown
 
Posts: n/a

Default Re: How to force UNIX line endings with BCP.EXE's -r option - 09-16-2008 , 05:12 PM






"Erland Sommarskog" wrote:

Quote:
Thomas W. Brown (thomas_w_brown (AT) countrywide (DOT) 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* to cook the line endings and treat \n
as just a linefeed?!?

You need to use a format file. In a format file \n means \n and not \r\n.

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se
Excellent, thanks!!

-- TB



Reply With Quote
  #13  
Old   
Thomas W. Brown
 
Posts: n/a

Default Re: How to force UNIX line endings with BCP.EXE's -r option - 09-16-2008 , 05:12 PM



"Erland Sommarskog" wrote:

Quote:
Thomas W. Brown (thomas_w_brown (AT) countrywide (DOT) 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* to cook the line endings and treat \n
as just a linefeed?!?

You need to use a format file. In a format file \n means \n and not \r\n.

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se
Excellent, thanks!!

-- TB



Reply With Quote
  #14  
Old   
Thomas W. Brown
 
Posts: n/a

Default Re: How to force UNIX line endings with BCP.EXE's -r option - 09-16-2008 , 05:12 PM



"Erland Sommarskog" wrote:

Quote:
Thomas W. Brown (thomas_w_brown (AT) countrywide (DOT) 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* to cook the line endings and treat \n
as just a linefeed?!?

You need to use a format file. In a format file \n means \n and not \r\n.

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se
Excellent, thanks!!

-- TB



Reply With Quote
  #15  
Old   
Thomas W. Brown
 
Posts: n/a

Default Re: How to force UNIX line endings with BCP.EXE's -r option - 09-16-2008 , 05:12 PM



"Erland Sommarskog" wrote:

Quote:
Thomas W. Brown (thomas_w_brown (AT) countrywide (DOT) 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* to cook the line endings and treat \n
as just a linefeed?!?

You need to use a format file. In a format file \n means \n and not \r\n.

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se
Excellent, thanks!!

-- TB



Reply With Quote
  #16  
Old   
Thomas W. Brown
 
Posts: n/a

Default Re: How to force UNIX line endings with BCP.EXE's -r option - 09-16-2008 , 05:12 PM



"Erland Sommarskog" wrote:

Quote:
Thomas W. Brown (thomas_w_brown (AT) countrywide (DOT) 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* to cook the line endings and treat \n
as just a linefeed?!?

You need to use a format file. In a format file \n means \n and not \r\n.

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se
Excellent, thanks!!

-- TB



Reply With Quote
  #17  
Old   
Thomas W. Brown
 
Posts: n/a

Default Re: How to force UNIX line endings with BCP.EXE's -r option - 09-16-2008 , 05:12 PM



"Erland Sommarskog" wrote:

Quote:
Thomas W. Brown (thomas_w_brown (AT) countrywide (DOT) 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* to cook the line endings and treat \n
as just a linefeed?!?

You need to use a format file. In a format file \n means \n and not \r\n.

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se
Excellent, thanks!!

-- TB



Reply With Quote
  #18  
Old   
Thomas W. Brown
 
Posts: n/a

Default Re: How to force UNIX line endings with BCP.EXE's -r option - 09-16-2008 , 05:12 PM



"Erland Sommarskog" wrote:

Quote:
Thomas W. Brown (thomas_w_brown (AT) countrywide (DOT) 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* to cook the line endings and treat \n
as just a linefeed?!?

You need to use a format file. In a format file \n means \n and not \r\n.

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se
Excellent, thanks!!

-- TB



Reply With Quote
  #19  
Old   
Thomas W. Brown
 
Posts: n/a

Default Re: How to force UNIX line endings with BCP.EXE's -r option - 09-16-2008 , 05:12 PM



"Erland Sommarskog" wrote:

Quote:
Thomas W. Brown (thomas_w_brown (AT) countrywide (DOT) 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* to cook the line endings and treat \n
as just a linefeed?!?

You need to use a format file. In a format file \n means \n and not \r\n.

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se
Excellent, thanks!!

-- TB



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.