SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 BCP and Carriage Return
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

SQLJames
Starting Member

29 Posts

Posted - 12/05/2012 :  17:48:53  Show Profile  Reply with Quote
I have a text file that I need to import using BCP. Lots of fields. The column delimiter is a comma while the row terminator is a carriage return. Here is the command that I am using:

BCP [Database].[Owner].[Table] IN "\\NetworkDevice\Folder1\DataToImport.csv" -c -T -S MyServer -t "," -r "\r\n"

The problem I am running into is that some fields have a carriage return \r\n in them and are causing the import grief. I am getting the following error:

SQLState = S1000, NativeError = 0
Error = [Microsoft][SQL Server Native Client 10.0]Unexpected EOF encountered in BCP data-file.

I tried a format file with the column delimiter and row delimiter specified too and nothing seems to work.

Any suggestions?

Thank you in advance for your consideration and time!

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 12/06/2012 :  02:13:09  Show Profile  Reply with Quote
can this be fixed at source? that would be best bet otherwise you've to parse individual lines and cleanse unwanted intermediate carriage returns before you do bcp. This can cause performance impact esp if file is huge

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

SQLJames
Starting Member

29 Posts

Posted - 12/06/2012 :  12:48:45  Show Profile  Reply with Quote
Thank you for your response. It is a vendor file and cleaning it at the source is not an option at this time. In the future that may be however it is not now. Luckily the file is not large and the processing-intensive option seems to be all that is available.

Thank you for your time!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 12/07/2012 :  08:19:04  Show Profile  Reply with Quote
then you can make use of script task in SSIS to parse individual rows and cleanse out carriage return . then use BULK INSERT or data flow task task to get data onto your table.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000