HiveBrain v1.2.0
Get Started
← Back to all entries
gotchasqlMinor

BCP woes: Unexpected EOF encountered in BCP data-file

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
fileencounteredbcpeofunexpectedwoesdata

Problem

I have a table defined as such:

CREATE TABLE [dbo].[IpMetadata](
    [StartIp] [bigint] NOT NULL,
    [EndIp] [bigint] NOT NULL,
    [CountryCode] [char](10) NOT NULL,
    [ProxyType] [varchar](50) NULL,
    [ProxyDescription] [varchar](50) NULL,
    [IspName] [varchar](100) NULL,
    [MobileCarrier] [varchar](50) NULL,
    [MobileCarrierCode] [varchar](50) NULL,
    [Latitude] [varchar](50) NULL,
    [Longitude] [varchar](50) NULL,
    [PostalCode] [varchar](50) NULL,
    [City] [varchar](50) NULL,
    [Region] [varchar](50) NULL,
    [Country] [varchar](50) NULL,
    [GmtOffset] [varchar](50) NULL,
    [SupportsDaylightSavings] [char](10) NULL,
    [MetroCode] [varchar](50) NULL,
    [AddressCount] [int] NOT NULL,
     CONSTRAINT [PK_IpMetadata] PRIMARY KEY CLUSTERED 
    (
        [StartIp] ASC,
        [EndIp] ASC
    )
)


I have a UTF-8 encoded sampling file (D:\data\ipsnip.csv) with tab-delimited, CRLF terminated rows to insert into this table like so:

```
#start-ip end-ip edge-two-letter-country proxy-type proxy-description isp-name mobile-carrier mobile-carrier-code edge-latitude edge-longitude edge-postal-code edge-city edge-region edge-country edge-gmt-offset edge-in-dst edge-metro-code address-count
0 0 0 0 0 0 reserved * *** +9999 n -1 0
1 255 0 0 0 0 reserved * *** +9999 n -1 254
256 16777215 0 0 0 0 reserved * *** +9999 n -1 16776959
16777216 16777343 au 0 -37.7596 145.134 3106 templestowe vic aus +1000 n 36211 127
16777344 16777407 au 0 -37.7596 145.134 3106 templestowe vic aus +1000 n 36211 63
16777408 16777471 au 0 -37.7596 145.134 3106 templestowe vic aus +1000 n 36211 63
16777472 16778239 cn chinanet fujian province network 0 26.0786 119.298 350000 fuzhou 35 ch

Solution

So it turns out that the -n and the -N are not what I wanted; I had assumed it used the db metadata to implicitly convert the incoming data, but it looks like it's expecting binary data with that.

I changed it to -c and it worked without issue.

Context

StackExchange Database Administrators Q#175654, answer score: 2

Revisions (0)

No revisions yet.