Enable Foreign Key T-SQL

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;

nametype_descis_disabled
FK_DEPT_IDFOREIGN_KEY_CONSTRAINT1

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;

nametype_descis_disabled
FK_DEPT_IDFOREIGN_KEY_CONSTRAINT0