MSSQL to MYSQL migration (check constraints into triggers)

192 views Asked by At

I am trying to figure out how to properly migrate a sql server database into a mysql database. Everything went OK beside the check constraints (and on update cascade).

Is there any way or tool to automatic transform CHECK constraint into triggers?

ALTER TABLE customer
ADD Constraint CK_customer_Sex
CHECK (Sex= 'M' OR Sex= 'F' );

into something like

CREATE TRIGGER `CK_customer_Sex` BEFORE INSERT ON `Sex`
    FOR EACH ROW
    BEGIN
        IF SEX <> 'M' or SEX <> 'F' THEN
        END IF;
END;

Unfortunately I can't manage to get the trigger working with error:

Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END IF' at line 5

0

There are 0 answers