Search This Blog

Sunday 4 January 2015

Temporarily avoid foreign key constraint in sql server


We can avoid foreign key constraint temporarly by using following code

--ALTER TABLE Station NOCHECK CONSTRAINT MyConstraint

ALTER TABLE TABLE_NAME NOCHECK CONSTRAINT FK_CONSTRAINTNAME

select * from TABLE_NAME where COLUMN_NAME='UPDATEDVALUE'

update TABLE_NAME set COLUMN_NAME='UPDATEDVALUE' where COLUMN_NAME='WHERECONDITION_VALUE'

select * from TABLE_NAME where COLUMN_NAME='WHERECONDITION_VALUE'
-- Enable single constraint

ALTER TABLE TABLE_NAME CHECK CONSTRAINT FK_CONSTRAINTNAME

Temporarily avoid foreign key constraint in sql server



1 comment:

  1. It was so nice article and useful to Informatica learners. we also provide Dotnet Course online training our Cubtraining is leader in providing Software Training

    ReplyDelete