Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 BULK INSERT error, any ideas?

Author  Topic 

rwklein1
Starting Member

5 Posts

Posted - 2005-01-06 : 20:51:34
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

nr
SQLTeam MVY

12543 Posts

Posted - 2005-01-07 : 00:56:51
Easiest to create a view on the table without the first column and bulk insert into that.
Or you can use a format file.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -