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 problem

Author  Topic 

srosenberg
Starting Member

3 Posts

Posted - 2009-04-17 : 10:25:04
I am trying to import a flat ascii file with 48 fields. I have not been able to get SQL to recognize the end of the row. The row terminator is a line feed. If I don't put in the ROWTERMINATOR qualifier (or if I put in ROWTERMINATOR = '\n') it gives me a data conversion error(type mismatch) for the last field of every row. The field is a money field and in the first ten records the value is 0.00

I tried regenerating my data with an asterisk at the end each row and put in ROWTERMINATOR = '*\n' This gave me an error saying that the last field in the line was too long. I also tried with ROWTERMINATOR = '*' and got the same result. I have carefully checked that the number of data fields in the input corresponds to the file description. My code is:
DROP TABLE PAYHIS3
CREATE TABLE PAYHIS3 (
EMPNO VARCHAR(5) NOT NULL,
CKDATE DATETIME NOT NULL,
CHECKNO VARCHAR(6) NOT NULL,
DFWITH MONEY,
DSWITH MONEY,
DMEDI MONEY,
DFICA MONEY,
D401P MONEY,
DPDMEDSUP MONEY,
DPTHLTH MONEY,
DCARE MONEY,
DCOLONIAL MONEY,
DGYM MONEY,
DPWDUEES MONEY,
DCLERDUES MONEY,
DPOLDUES MONEY,
DSUNSHINE MONEY,
DI457 MONEY,
DTM401A MONEY,
DAETNA MONEY,
DUNWAY MONEY,
DTOY MONEY,
DPWNEEDS MONEY,
DPBUY MONEY,
DROTH MONEY,
DATTACH MONEY,
DMBUY MONEY,
DDIRDEP MONEY,
DPD1PCT MONEY,
DVROTH MONEY,
DPHTSING MONEY,
DPHTWND MONEY,
DPHTWNF MONEY,
DPHPWS MONEY,
DPHPWD MONEY,
DPHPWF MONEY,
DPDRET MONEY,
DTWNRET MONEY,
DLOAN MONEY,
DTWN5PCT MONEY,
DCRUN MONEY,
DTWNSUPP MONEY,
DADVANCE MONEY,
DGRPLIF MONEY,
DNONCASH MONEY,
DMAWITH MONEY,
DELCPCT MONEY,
DPOLBUY MONEY
)
BULK INSERT PAYHIS3 FROM '\\ROSENSAN\FRONTEND\PAYHIS3.TXT' WITH
(FIELDTERMINATOR = ',',ROWTERMINATOR = '\n',
FIRSTROW = 1)

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2009-04-17 : 10:35:38
try ROWTERMINATOR = '0x0a',

"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking
Go to Top of Page

srosenberg
Starting Member

3 Posts

Posted - 2009-04-17 : 11:06:41
Thanks for the suggestion. Unfortunately it didn't work. I also tried using '''+ nchar(10)+''' and it didn't work either. I have been experimenting by taking out some of the fields and moving fields around without any success. I did this same process with the same programs and no problem about 8 months ago.
Go to Top of Page

srosenberg
Starting Member

3 Posts

Posted - 2009-04-17 : 14:59:54
I solved the problem. I have just spent two days looking at the wrong input files. The directory my query was taking the data from was not the directory where I was putting the data. So the problem really was that the files did not match the fields in the query.
Go to Top of Page

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2009-04-17 : 15:02:43
Don't you wish computers did what you wanted and not what you asked them to do.

"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking
Go to Top of Page
   

- Advertisement -