Search code examples
mysqlcsvnullheidisql

HeidiSQL import csv empty fields


I want to import a csv file to my MySQL database with HeidiSQL.

But some of my fields are empty.

What could I do to let HeidiSQL know these empty values have to be seen as NULL-values?

Sample of csv-file (last 2 fields not yet known):

    NULL;Students Corner;437452182;;

Create commands:

    CREATE  TABLE `db`.`customers` (
         `company_id` INT NOT NULL AUTO_INCREMENT ,
         `company_name` VARCHAR(40) NULL ,
         `company_number` INT NULL ,
         `company_vat` INT NULL ,
         `company_zip` INT NULL,
    PRIMARY KEY (`company_id`) );

I get these error:

    Incorrect integer value: '' for column 'company_id' at row 1 */
    Incorrect integer value: '' for column 'company_vat' at row 1 */
    Incorrect integer value: '' for column 'company_zip' at row 1 */
    etc

Solution

  • If solved it by writing \N in each empty field instead of writing NULL !