riza
riza

Reputation: 51

Import text file to SQL Server using Bulk Insert

This is my sql

BULK INSERT dbo.Account FROM 'G:\Import\Account3.txt'
WITH
(
    FIELDTERMINATOR = '" | "'
)
GO

When I run the sql i got this error

Msg 4866, Level 16, State 1, Line 1
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 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)".

Please help me. I already tried many ways but still get the same error.

Upvotes: 5

Views: 53411

Answers (2)

Tom Lint
Tom Lint

Reputation: 499

From your example SQL, it seems you are missing a ROWTERMINATOR statement, specifying how rows are to be differentiated from one another.

Your query would then become something like

BULK INSERT dbo.Account FROM 'G:\Import\Account3.txt'
WITH
(
FIELDTERMINATOR = '" | "',
ROWTERMINATOR = '\r\n'
)
GO

Upvotes: 5

user1827371
user1827371

Reputation: 39

Try this

BULK
INSERT dbo.Account 
FROM 'G:\Import\Account3.txt'
WITH
(
FIELDTERMINATOR = '|',
ROWTERMINATOR = '\n'
)
GO

Upvotes: -1

Related Questions