Categories
MSSQL Server

MSSQL Enable/Disable Indexes and Constraints (QuickRef)

Enable or disable a foreign key constraint.

ALTER TABLE dbo.TableName [NO]CHECK 
CONSTRAINT [FK_TableName_FTableName_IDColumn|ALL];

Enable or disable an index.

ALTER INDEX [IX_TableName_IndexName|ALL] 
ON dbo.TableName [DISABLE|REBUILD];

Recreate an index

CREATE INDEX IX_TableName_IndexName ON dbo.TableName(ColumnName) 
WITH ( DROP_EXISTING = ON );