Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems importing from text file

Status
Not open for further replies.

Sylv4n

Technical User
Feb 27, 2002
83
GB
Hi, I'm trying to import values from a text file into a mySQL database, the table I'm using is
-------
CREATE TABLE tblAllocate
(
AllocateID int not null auto_Increment primary key,
AllocatedUSer varchar(35),
AllocatedComputer varchar(6),
AllocationChecked date
);
-------

and I'm importing with:
-------
LOAD DATA LOCAL INFILE 'C:/testbed/tables/automated/out.txt'
INTO TABLE tblAllocate
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r'
(AllocateID,AllocatedUser,AllocatedComputer,AllocationChecked);
-------

and the text file looks like:
-------
3,aaaa111,697567,\N \r
4,aaaa112,697568,\N \r
5,aaaa113,697569,2006/08/16 \r
7,aaaa114,697571,\N \r
8,aaaa115,697572,2006/08/21 \r
10,aaaa116,697574,2006/08/22 \r
-------

Now the problem is that the Null "\N" isnt working on the last col, I just get a default date of 0000-00-00 whereas I want null. those with dates in are being imported fine.

I was having a simmilar problem imporing to another table but the date was working fine but the last col would not import a null value

Any ideas what I'm doing wrong?
 
ahh figured it out, I needed to remove the end of line marker of '/r' and use '/r/n' which is a windows way of ending a file
Working fine now =)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top