SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


BCP in UNIX files


BCP in UNIX files

Author
Message
Ian C0ckcroft
Ian C0ckcroft
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1236 Visits: 863
Hi guys. I am importing files from A SAP extract which use a UNIX format. The carriage return in UNIX is {LF} (LINE FEED).
How do I either convert the file to PC format easily or use {LF} in the BCP argument?
This is my CMD command for BCP.

C:\Program Files\Microsoft SQL Server\100\Tools\Binn>bcp "BI_STAGING.[SAPecc6].[Staging_VendorBCPTest]" in "T:\Business Intelligence\SAP Extracts\20120627_data_Vendor.txt" -c -t"|"[b] -r{LF} [b]-F2 -T -S "03RNB-BIW01\BIDW"

the following dont work. -r{LF}, -r\LF, -r"LF"

Once I get it working in CMD, I will create a packege for it.

ANy ideas?
thanks
Ian

Ian Cockcroft
MCITP BI Specialist
Orlando Colamatteo
Orlando Colamatteo
SSC-Forever
SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)

Group: General Forum Members
Points: 40264 Visits: 14413
You posted this in the Integration Services forum so why use bcp? Why not SSIS? If you do in fact need bcp you'll have to use a format file to specify the end of line char. Unfortunately when specifying on the command line using -r bcp prepends it with \r resulting in a runtime value of \r, which is not what you need.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Ian C0ckcroft
Ian C0ckcroft
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1236 Visits: 863
Hi, thanks for the reply.
we originally were using a script to pick up the files and build staging tables based on the file content and then use bcp to load them. If the file layout changed, we could handle it easier once it was in SQL.

have had a rethink and we going to use SSIS data flow going forward. if the files change, to bad, their fault.

Ian Cockcroft
MCITP BI Specialist
Arjen Krap
Arjen Krap
SSC-Enthusiastic
SSC-Enthusiastic (147 reputation)SSC-Enthusiastic (147 reputation)SSC-Enthusiastic (147 reputation)SSC-Enthusiastic (147 reputation)SSC-Enthusiastic (147 reputation)SSC-Enthusiastic (147 reputation)SSC-Enthusiastic (147 reputation)SSC-Enthusiastic (147 reputation)

Group: General Forum Members
Points: 147 Visits: 215
On Unix/Linux systems there is command called unix2dos which can convert LF text files to CRLF text files. Otherwise the same is possible with sed, awk, perl, etc.

Also most ftp servers can convert uncompressed text files from LF format to CRLF format on the fly by using ASCII transfer instead of binary transfer. So if you are already using ftp to transfer the files on a local area network this could be an option.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search