Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
04-18-2009, 01:58 AM #1
- Join Date
- Feb 2009
- Los Angeles
- Thanked 1 Time in 1 Post
CSV upload - AUTO INCREMENT field?
I need to upload a CSV file to a new table. If the Primary id field is auto incremented, what do I fill the column cells with in Excel? I've tried "0", NOT NULL, and just leaving the column blank.
I could just fill it in with numbers on the file in Excel, but what if I'm adding to an existing table? Isn't there something more automatic?
This doesn't work the same as leaving that field blank in PHPMyAdmin, which is what I'm using to upload the file.
04-18-2009, 07:03 AM #2
I *think* you need to use NULL.
Certainly when you use a simple SQL command and you include the autoincrement column in the list of fields, you use NULL in the values. That is:
Dunno if a textual NULL in the CSV file will work, though.Code:INSERT INTO table ( autoinc, f1, f2 ) VALUES( null, 'xxx', 'yyy' )
Why not just omit the field???
The SQL I gave above is semantically the same as:
Haven't done this with MySQL. Have with SQL Server, but SQL Server's DTS is very very flexible.Code:INSERT INTO table ( f1, f2 ) VALUES( 'xxx', 'yyy' )