除非我再次保存csv,否则大容量插入不会工作

8mmmxcuj  于 2021-07-29  发布在  Java
关注(0)|答案(0)|浏览(254)

我已经下载了r中的数据,并将其放入csv中,我想将其插入数据库。

set nocount on Bulk Insert dbo.Raw_BM086_Daily_Meter_Data_Report 
from 'C:/Filename.csv
WITH (FIRSTROW = 2,FIELDTERMINATOR=',',ROWTERMINATOR='\n',BATCHSIZE=250000,MAXERRORS=1);

在SQLServer中运行大容量插入查询时,出现以下错误。

Msg 4864, Level 16, State 1, Line 41
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 2, column 1 (ID).
Msg 4864, Level 16, State 1, Line 41
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 3, column 1 (ID).
Msg 4865, Level 16, State 1, Line 41
Cannot bulk load because the maximum number of errors (1) was exceeded.
Msg 7399, Level 16, State 1, Line 41
The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7330, Level 16, State 2, Line 41
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".

该表的结构如下:

CREATE TABLE Raw_Table(
ID BigINT NOT NULL IDENTITY(1, 1), 
Date Date,
Participant varchar(32),
ResourceName varchar(32),
ResourceType char(3),
StartTime Datetime,
EndTime Datetime,
Jurisdiction char(3),
Meter numeric (8,3),
PRIMARY KEY(ID)
);

原始数据如下所示:

Date    Participant ResourceName    ResourceType    StartTime   EndTime Jurisdiction    Meter

1 20200723 pt\ U 400109 gu\ U 401350 gen 2020-07-23t19:30:00 2020-07-23t20:00 xyz 0.329 2 20200723 pt\ U 400087 gu\ U 401230 gen 2020-07-23t19:30:00 2020-07-23t20:00 xyz 8.519 3 20200723 pt\ U 400085 gu\ U 401140 gen 2020-07-23t19:30:00 2020-07-23t20:00 xyz 0
当我打开csv并保存它,而不做任何其他事情,并运行我的大容量插入查询它的作品完美。
这是非常令人沮丧的-我想自动化的过程,并避免保存csv手动获得批量插入工作

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题