Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
SQLJames
Starting Member
35 Posts |
Posted - 2012-12-05 : 17:48:53
|
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 = 0Error = [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
52326 Posts |
Posted - 2012-12-06 : 02:13:09
|
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 MVPhttp://visakhm.blogspot.com/ |
|
|
SQLJames
Starting Member
35 Posts |
Posted - 2012-12-06 : 12:48:45
|
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! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-12-07 : 08:19:04
|
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 MVPhttp://visakhm.blogspot.com/ |
|
|
rspiet
Starting Member
1 Post |
Posted - 2014-12-30 : 12:19:36
|
I know this is an old thread, but I had carriage returns in my data. I did not want them filtered out.I used the -n parameter (native format) instead of the -c parameter and it worked fine for me.Raymond S. Pietrzak |
|
|
|
|
|