Bulk Load fails when I uncomment the rownum line with the following errors. I know the workaround for this issue. But I need to understand why does it show error message.
当我取消注释rownum行时出现以下错误,批量加载失败。我知道这个问题的解决方法。但我需要理解为什么它会显示错误信息。
Msg 4866, Level 16, State 1, Line 41
The bulk load failed. The column is too long in the data file for row 1, column 1. Verify that the field terminator and row terminator are specified correctly.Msg 4866,Level 16,State 1,Line 41批量加载失败。第1行第1列的数据文件中的列太长。验证是否正确指定了字段终止符和行终止符。
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.消息7399,级别16,状态1,行41链接服务器“(null)”的OLE DB提供程序“BULK”报告错误。提供商未提供有关错误的任何信息。
Msg 7330, Level 16, State 2, Line 41
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".消息7330,级别16,状态2,行41无法从OLE DB提供程序“BULK”获取链接服务器“(null)”的行。
Code:
CREATE TABLE #TEMPFILE
(
LINE VARCHAR(5000)
,rownum int identity(1,1) primary key
)
EXEC('BULK INSERT #TEMPFILE FROM '''+ @FILENAME + ''' WITH (ROWTERMINATOR = ''0x0a'', lastrow = 1) ')
1 个解决方案
#1
1
This is the syntax i have used for bulk insert in SQL Server
这是我在SQL Server中用于批量插入的语法
BULK
INSERT Table_Name
FROM FileName/FilePath
WITH
(
FIRSTROW = 2,
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
#1
1
This is the syntax i have used for bulk insert in SQL Server
这是我在SQL Server中用于批量插入的语法
BULK
INSERT Table_Name
FROM FileName/FilePath
WITH
(
FIRSTROW = 2,
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)