1

I am trying to write a data-definition query to add a constraint to a table that enforces referential integrity

ALTER TABLE SS_SIZE ALTER COLUMN NDS TEXT 
CONSTRAINT fk_NDS REFERENCES NDS (NDS) ON UPDATE CASCADE ON DELETE CASCADE

I've also tried

ALTER TABLE SS_SIZE ALTER COLUMN NDS 
CONSTRAINT fk_NDS_NDS FOREIGN KEY (NDS) REFERENCES NDS ON UPDATE CASCADE ON DELETE CASCADE

Neither of these will work.

Sergey S.
  • 6,296
  • 1
  • 14
  • 29

1 Answers1

2

Try this:

ALTER TABLE SS_SIZE 
    ADD CONSTRAINT fk_NDS FOREIGN KEY (NDS) 
        REFERENCES NDS (NDS) ON UPDATE CASCADE ON DELETE CASCADE

Please note, that DAO doesn't support ON UPDATE CASCADE ON DELETE CASCADE options, you should use ADO for this. Query designer uses DAO, so you won't be able to execute the query with cascade options using query designer.

VBA ADO example:

CurrentProject.Connection.Execute strSQL
Sergey S.
  • 6,296
  • 1
  • 14
  • 29