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: Thursday, July 24, 2014 4:11 AM
Points: 853, Visits: 787
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 2, 2012 12:03 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 7:44 PM
Points: 7,107, Visits: 12,661
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
Post #1338957
Posted Thursday, August 2, 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: Thursday, July 24, 2014 4:11 AM
Points: 853, Visits: 787
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 4, 2012 3:20 PM


Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, September 25, 2014 7:34 AM
Points: 51, Visits: 184
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