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
 General SQL Server Forums
 New to SQL Server Programming
 Me again - importing txt file into a sql table

Author  Topic 

pjnovak007
Starting Member

19 Posts

Posted - 2010-04-08 : 17:07:07
Newbie trying learn today:

I am trying to import a txt file in a table

File is C:\car\use.txt

database name is: CarTest
table name is: CarINV

I want to import exactly what is in teh use.txt file and i am getting errors. I have have used (2) code:

1.) Insert into CarINV Select * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=c:\car\4-8-2010.xls;HDR=YES',
'SELECT * FROM [Deal$]')

1-error.) Msg 8114, Level 16, State 5, Line 1
Error converting data type nvarchar to float.
-------------------------------------------------------
2.) BULK INSERT CarINV
FROM 'c:\car\use.txt'
WITH
(
FIRSTROW = 2,
MAXERRORS = 0,
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)

2-error.)Msg 4864, Level 16, State 1, Line 1
Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 2, column 1 (DEALER_ID).
Msg 7399, Level 16, State 1, Line 1
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 1
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".






Patrick

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-04-09 : 02:21:13
What is the datatype of DEALER_ID column?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

pjnovak007
Starting Member

19 Posts

Posted - 2010-04-09 : 08:34:46
it's just a 3 digit number so could i have that setup incorrectly?

Patrick
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-04-09 : 08:49:46
quote:
Originally posted by pjnovak007

it's just a 3 digit number so could i have that setup incorrectly?

Patrick


Are the data available in the text file of the same type for that column?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -