Priyesh
Priyesh

Reputation: 11

SQL Server : why does Bulk Load fail?

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.

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 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)".

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)  ')

Upvotes: 0

Views: 762

Answers (1)

Ryan Gadsdon
Ryan Gadsdon

Reputation: 2378

This is the syntax i have used for bulk insert in SQL Server

BULK
INSERT Table_Name
FROM FileName/FilePath
WITH
(
  FIRSTROW = 2,
  FIELDTERMINATOR = ',',
  ROWTERMINATOR = '\n'
)

Upvotes: 1

Related Questions