How to recheck primary/foreign key constraint for data already in the table in sql server? -
i have table in sql server 2005 foreign key , disable huge data loading, , re-enabled:
example:
alter table table1 nocheck constraint fk_1 go lots of inserts... go alter table table1 check constraint fk_1 go
now, question: there way re-check inserted data?
the syntax looks little silly word "check" repeated, want is:
alter table table1 check check constraint fk_1 go
adding "with check" option validate existing data against constraint. doing prevent constraint becoming untrusted.
if existing data violates constraint, you'll error this:
the alter table statement conflicted check constraint "fk_1".
Comments
Post a Comment