Book a Demo

Author Topic: DDL for SQL server generates ON DELETE RESTRICT  (Read 4031 times)

micke911

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
DDL for SQL server generates ON DELETE RESTRICT
« on: February 15, 2012, 11:35:06 pm »
I am working on a data model targeted at SQL-server 2008. Running the command Tools/Database Engineering/Generate Package DDL generates the following constraint declaration in the result file:

Code: [Select]
ALTER TABLE schma.tbl ADD CONSTRAINT FK_RefTbl
      FOREIGN KEY (RefID) REFERENCES schma.reftbl (ID)
      [highlight]ON DELETE RESTRICT ON UPDATE RESTRICT[/highlight]
GO

ON DELETE RESTRICT ON UPDATE RESTRICT is not valid for SQL server 2008. Is this a bug?

philchudley

  • EA User
  • **
  • Posts: 750
  • Karma: +22/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Re: DDL for SQL server generates ON DELETE RESTRIC
« Reply #1 on: February 16, 2012, 12:35:48 am »
Check the relationship between the tables, right-click and select Foreign Keys...

You will most likely find that referential integrity has been checked on, hence the clause in the DDL

Unchecking the referential integrity checks will generate the DDL you expect

Cheers

Phil
Models are great!
Correct models are even greater!

micke911

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: DDL for SQL server generates ON DELETE RESTRIC
« Reply #2 on: February 16, 2012, 08:57:42 pm »
Yes that seems to be the workaround. Since the RESTRICT directives are not valid in SQL server I think it would be correct not to have this as a default in the foreign key dialog.

Thanks a lot!

/Micke