Alex Gordon
Alex Gordon

Reputation: 60882

Error when importing a file into SQL Server

I am trying to import into SQL Server 2008 using:

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


DECLARE @stmt NVARCHAR(2000);


SET @stmt = '
  BULK INSERT accn_ordered_tests
   FROM ''e:\fullextract\accn_ordered_tests_201201270801.txt''
   WITH 
      (
        firstrow=2,
FIELDTERMINATOR = ''|''  ,
ROWS_PER_BATCH=10000

   ,ROWTERMINATOR='''+@row_terminator+'''
   )'
exec sp_executesql @stmt;

This statement has been working fabulously for hundreds of tables.

I am running into a problem with one table. Here's a sample of the data:

DD68|OXY-2|Oxycodone Panel|N||83925|FEE|TRICORTH|INC|||||1|N|N|||1|25.94|68.45|68.45|0|||N|48035|N||0|04/05/2011|N||69872|7739|12/13/2011 10:12:29|04/07/2011||0|0|||||0
D088|PCP-2|Phencyclidine panel|N||83992|FEE|TRIORTH|IWC|||||1|N|N|||1|19.6|51.7|51.7|0|||N|41636|N||0|04/05/2011|N||69873|7740|12/13/2011 10:12:29|04/07/2011||0|0|||||0
D858|PPX-2|Propoxyphene panel|N||83925|FEE|TRIORTH|IWC|||||1|N|N|||1|25.94|68.45|68.45|0|||N|41037|N||0|04/05/2011|N||69874|7741|12/13/2011 10:12:29|04/07/2011||0|0|||||0
DD68|TAP-2|Tapentadol panel 80299|N||80299|FEE|TRICATH|INC|||||1|N|N|||1|1|48.18|48.18|0|||N|48038|N||0|04/05/2011|N||69875|7745|12/13/2011 10:12:29|04/07/2011||0|0|||||0

i am getting this error:

Msg 4866, Level 16, State 1, Line 2
The bulk load failed. The column is too long in the data file for row 72294, column 36. Verify that the field terminator and row terminator are specified correctly.
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)".

Does anyone know what am I doing wrong?

Here is the row in question:

D858|PCP-2|Phencyclidine panel|N||83992|FEE|TRICARRTH|INC|||||1|N|N|||1|19.6|51.7|51.7|0|||N|4168036|N||0|04/05/2011|N||69873|7740|12/13/2011 10:12:29|04/07/2011||0|0|||||0

When I tried to do the IMPORT DATA WIZARD I got these error:

overflowed the disk I/O buffer for column audit_date

Upvotes: 1

Views: 665

Answers (1)

HLGEM
HLGEM

Reputation: 96650

LIkely you have a bad file. Ask the vendor to resend it.

Upvotes: 1

Related Questions