jeudi 3 décembre 2015

The check keyword not working in sql management studio

I have two tables tblA and tblB. And a constraint called tblA_tblB_FK is created between these tables. I wanted to update both columns in tables chained with tblA_tblB_FK constraint. While reading different posts I thought the best way is to disable the constraint for a moment and enable again after the update. For that reason I executed these queries:

alter table tblA NOCHECK CONSTRAINT tblA_tblB_FK

After this step I did the update and till now everything was OK, but then I tried to enable again the constraint, so I executed this query:

ALTER TABLE tblA CHECK CONSTRAINT tblA_tblB_FK

and it says command successfully completed. But when I try to make update again it doesn't stop me from doing that, meaning there is a problem with the enabling process. I tried to execute another query:

ALTER TABLE tblA WITH CHECK CHECK CONSTRAINT tblA_tblB_FK

and it doesn't allow me complaining there is tblA_tblB_Fk constraint active. I don't understand why it allows me to make an update, while it doesn't allow me to execute this command?

I am using SQL Server 2005. Thanks in advance for any suggestions!

Aucun commentaire:

Enregistrer un commentaire