Bulk INSERT 不插入数据

Bulk INSERT not inserting data

当运行management studio下面的代码显示设置错误时。

我需要通过 BULK INSERT 将简单的文本数据插入到表中。插入代码如下:

BULK INSERT Pais FROM 'C:\[bulkdata]\shared-Pais.txt' 
WITH(MAXERRORS = 0, CODEPAGE = 'ACP', FIELDTERMINATOR = 'ø', ROWTERMINATOR = '\n', KEEPNULLS,
ERRORFILE = 'C:\[bulkdata]\shared\teste.txt')

我用来测试这个命令的文件只有一行用于插入数据, teste.txt:

BrasilØ01058

返回错误如下:

Msg 4832, Level 16, State 1, Line 1
Bulk load: An unexpected end of file was encountered in the data file.
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.
Msg 7330, Level 16, State 2, Line 1
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".

teste.txt:

BrasilØ01058BrasilØ01058

在我看来,这是试图在同一行中两次插入值,但正如设置所示,它通常会插入到其他项目中。我的用户可以未经许可吗?我已经创建了一个具有所有权限的特定用户,并且还设置了服务器执行批量操作的权限。

teste.txt.Error.Txt:

Row 1 File Offset 0 ErrorFile Offset 0 - HRESULT 0x80004005

这似乎是一个 character 的问题,您可以尝试使用另一个类似 § 的问题。 你只需要做一点调整:

FIELDTERMINATOR = '§'

还有你的 01-Pais.txt 文件:

Brasil§01058     

Update: It seems that also a mix of database collation and file encoding issue, could have messing up the bulk operation. Saving the file as ANSI, instead of UTF-8 seems to have corrected the original issue. It seems that also using CODEPAGE=1252 or DATAFILETYPE = 'widechar' should have fixed the issue.