BULK INSERT error, any ideas?

  • Here's my procedure (see below), when I run I get this error:

    "Bulk Insert data conversion error (type mismatch) for row 1, col 1"

    How do I have BULK INSERT load my first column (defined as Identity, Seed=1, Increment=1)... this is my first problem.

    The first column of my source text file needs to go into 2nd col of my table. 1st col of my table is for a unique key (Identity).

    (added KEEPIDENTITY and it didn't seem to make a difference).

    Am totally new to SQL Server, please help, thanks.

    --------------------------

    CREATE PROCEDURE test AS

    TRUNCATE TABLE mytable

    EXEC sp_dboption "mydatabase", "select into/bulkcopy", TRUE

    BULK INSERT mydatabase.owner.[mytable]

    FROM 'C:\abc.txt'

    WITH (

    DATAFILETYPE = 'char',

    FIELDTERMINATOR = '","',

    TABLOCK

    )

    GO

  • Try adding the following before the insert.

    SET IDENTITY_INSERT [ database. [ owner. ] ] { table } { ON | OFF }

     

    Use the ON parameter and it should ignore you trying to put an identity value in for sure. If you still get an error you need to look at the data itself.

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

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