Sunday, February 12, 2012

Constraint disabling

Hi,

Is there any way to disable/enable constraints on the table?

Command "ALTER TABLE table_name {CHECK|NOCHECK} CONSTRAINT ALL" produces error.

Hi,

Use this :

alter table YourTableNameWithConstraint drop constraint [CONSTRAINT_NAME]

Babak Izadi
LotraSoft Ltd.

|||This drops (removes) constraint, but I need only disable it for a time.|||

ALTER TABLE Your_Table_Name NOCHECK CONSTRAINT Constraint_Name

Babak Izadi
LotraSoft Ltd.

|||The command you provided fails with error too. Seems this syntax is not supported.

Is there any posibility to temporarily disable all foreign-key constraints on a table?
I need to load data without checks and then enable them. Maybe there is some other way to do this?|||You can try

ALTER TABLE tablename
CONSTRAINT constraintname
REFERENCES table
ON DELETE NOACTION
ON UPDATE NOACTION|||
"No action" action is the default for reference constraints.

"If NO ACTION is specified, SQL Server Compact Edition returns an error, and the

update action on the referenced row in the parent table is rolled back." - this is what I'm trying to avoid.

No comments:

Post a Comment