0

Am using this BULK INSERT command to insert a csv file in SQL Server 2012 Express.

BULK INSERT dbo.TS_FX
   FROM 'c:\fxRates.csv'
   WITH 
   (
      FIELDTERMINATOR =',',
      ROWTERMINATOR =',\n'
   );

The First Row on the fxRatesCSV file looks like this:

101,20130430,20130531,1.5307

The error I get is:

Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 4 (FX_RATE).

My table (dbo.TS_FX) has 4 columns in it defined as follows

CURRENCY_ID (Numeric(3,0), null)
BEGIN_DATE (date, null)
END_DATE (date, null)
FX_RATE (float, null)

Clearly the error is the way I have defined the FX_RATE column, I have tried various other types (Decimal, Numeric) but I still get the same error

Any help is much appreciated.

Thanks

4

1 回答 1

0

从 ROWTERMINATOR 中删除逗号

您的 BULK INSERT 语句应如下所示:

BULK INSERT dbo.TS_FX
FROM 'c:\fxRates.csv'
WITH (
     FIELDTERMINATOR =','
    ,ROWTERMINATOR ='\n'
);
于 2013-06-15T15:55:45.620 回答