我需要将 csv 文件插入 sql server db。问题是我不断得到一个
Bulk load data conversion error (type mismatch or invalid character for
the specified codepage) error. this is repeated 10 times and
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "BULK" for linked server "(null)" reported an error.
The provider did not give any information about the error.
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".
错误的特定列是 bigint,主键,无空字段。我确保所有 5000 条记录都有一个 4 位数字并且没有空值。我厌倦了与此作斗争,只想将日期和数据值字段插入此表--CSResult。问题是 sql server 只是出错了,我认为它需要所有字段的值。有没有办法将数据插入到我想要的列中?有任何想法吗。
BULK INSERT [DB].[CsSchema].[CsResult] (
FROM 'c:\june132012.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
这是数据的样子:
3857,2011-05-19 04:00:00.000,Y,,82,N,N,,4,1,1,10,,1,,535/31706815
3858,2011-05-19 02:23:00.000,Y,,128,N,N,,4,1,1,10,,1,,535/31706815
这是 DDL:
ResultID bigint notnull
ResultDate datetime,notnull
HasValue CHAR 1, notnull
Duration int, null
DataValue decimal 19,9, notnull
IsEdited CHAR 1, notnull
IsAnnotated CHAR 1, notnull
AddOnValue decimal 19,9, null
DataTypeID FK, int, notnull
ResultTypeID FK smallint, notnull
PatientID FK, int, notnull
DataSourceTypeID FK, smallint, notnull
MedicationID FK, int, null
DataDownloadID FK, int, null
SlotTypeID FK,smallint, null
DataSourceIdentity nvarchar 20, null