Bulk Insert truncates data file

  • I've been attempting to use BULK INSERT to pull in data from a tab-delimited text file, like so :):

    
    
    BULK INSERT tbl_raw_data
    FROM 'D:\raw_data.txt'
    WITH (
    FIELDTERMINATOR = '\t',
    FIRSTROW = 3,
    KEEPNULLS,
    ROWTERMINATOR = '\n'
    )

    This code executes just fine, with one exception--it consistently imports 5088 records, while the same data file imported with DTS consistently provides 5161 records. What gives?

    I'd really appreciate any help; this problem has been plaguing me for the past 4 hours.

  • quote:


    
    
    BULK INSERT tbl_raw_data
    FROM 'D:\raw_data.txt'
    WITH (
    FIELDTERMINATOR = '\t',
    FIRSTROW = 3,
    KEEPNULLS,
    ROWTERMINATOR = '\n'
    )

    I discovered the issue today. The source of the data I'm using is an export from another database. Unfortunately, that joker created a tab-delimited export, but if the last two columns are empty, only a newline character is at the end of the line. So bulk insert would read the first 6 columns correctly, then the last column would equal the entire next line.

    I simply changed over to the fixed field-length data file, and used a format file for bulk insert.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply