Enable Foreign Key Constraint Example
To Enable a foreign key constraint, use the command alter table with CHECK constraint.
Status Foreign Key
select
name, type_desc, is_disabled
from sys.foreign_keys;
name | type_desc | is_disabled |
---|---|---|
FK_DEPT_ID | FOREIGN_KEY_CONSTRAINT | 1 |
Enable Foreign Key Constraint
USE tempdb;
GO
ALTER TABLE dbo.EMPLOYEES
CHECK CONSTRAINT FK_DEPT_ID;
GO
Status Foreign Key
select
name, type_desc, is_disabled
from sys.foreign_keys;
name | type_desc | is_disabled |
---|---|---|
FK_DEPT_ID | FOREIGN_KEY_CONSTRAINT | 0 |