gpt4 book ai didi

sql - 确定在 BULK INSERT 中导致 "unexpected end of file"错误的 ROW?

转载 作者:行者123 更新时间:2023-12-02 00:33:25 25 4
gpt4 key购买 nike

我正在进行批量插入:

DECLARE @row_terminator CHAR;
SET @row_terminator = CHAR(10); -- or char(10)

DECLARE @stmt NVARCHAR(2000);
SET @stmt = '
BULK INSERT accn_errors
FROM ''F:\FullUnzipped\accn_errors_201205080105.txt''
WITH
(
firstrow=2,
FIELDTERMINATOR = ''|'' ,
ROWS_PER_BATCH=10000
,ROWTERMINATOR='''+@row_terminator+'''
)'
exec sp_executesql @stmt;

并且收到以下错误:

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

有没有办法知道这个错误发生在哪个行?

我能够毫无问题地导入 10,000,000 行,之后会发生错误

最佳答案

要找到有问题的行,请使用错误文件说明符。

BULK INSERT myData
FROM 'C:\...\...\myData.csv'
WITH (
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n',
ERRORFILE = 'C:\...\...\myRubbishData.log'
);

myRubbishData.log 将包含有问题的行和一个伴随文件myRubbishData.log.txt 将为您提供文件中的行号和偏移量。

配套文件示例:

Row 3 File Offset 152 ErrorFile Offset 0 - HRESULT 0x80004005
Row 5 File Offset 268 ErrorFile Offset 60 - HRESULT 0x80004005
Row 7 File Offset 384 ErrorFile Offset 120 - HRESULT 0x80004005
Row 10 File Offset 600 ErrorFile Offset 180 - HRESULT 0x80004005
Row 12 File Offset 827 ErrorFile Offset 301 - HRESULT 0x80004005
Row 13 File Offset 942 ErrorFile Offset 416 - HRESULT 0x80004005

关于sql - 确定在 BULK INSERT 中导致 "unexpected end of file"错误的 ROW?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10507162/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com