BULK INSERT - Limitation ?

  • Hi all,

    Steps to reproduce

    I have created sample table “CSVTest” on in db, having fields as id, first name and last name.

    To import data using bulk insert please use following SQL. I have shared “sample.txt”.

    BULK INSERT CSVTest

    FROM '\\mymachine\import\sample.txt'

    WITH

    (

    FIELDTERMINATOR = ',',

    ROWTERMINATOR = ''

    )

    --- Data in Sample.text (NOTICE: NEWLINE at the end of file) --

    1,James,

    2,BK,

    ------- End of data----

    It inserts data properly with 2 rows.

    Try the same query, but change data as

    --- Data in Sample.text (NOTICE: NO NEWLINE at the end of file & NO data at last row last column) --

    1,James,

    2,BK,

    ------- End of data----

    PROBLEM: Only first row get inserted and second row is not.

    Try the same query, but change data as

    --- Data in Sample.text (NOTICE: NO at the end of file & NO data at last row last column) --

    1,James,

    2,BK,SD

    ------- End of data----

    It inserts 2 rows 🙂

    One way to solve problem is to add NEWLINE at end, but this is fix and not solution.

    Are there any other ways to solve this ?

  • Please don’t create multiple threads for one problem.

    http://qa.sqlservercentral.com/Forums/Topic1228778-357-1.aspx

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

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