Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

BCP in UNIX files Expand / Collapse
Author
Message
Posted Tuesday, July 31, 2012 6:55 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 4:23 AM
Points: 842, Visits: 741
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
Post #1337868
Posted Thursday, August 02, 2012 12:03 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 5:44 PM
Points: 6,703, Visits: 11,734
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

Believe you can and you're halfway there. --Theodore Roosevelt

Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein

The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein

1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
Post #1338957
Posted Thursday, August 02, 2012 1:35 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 4:23 AM
Points: 842, Visits: 741
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
Post #1338980
Posted Saturday, August 04, 2012 3:20 PM


Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Sunday, April 07, 2013 1:20 PM
Points: 51, Visits: 161
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.
Post #1340221
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse