Readers often ask how to disable and enable all constraint for table and database. Here are simple ALTER TABLE scripts for both, plus one for a single constraint.
Foreign Keys Without Indexes: Finding and Fixing Slow Deletes
Find foreign keys without indexes, inspect parent-delete plans, and choose leading child-table keys that support relationship checks.
SQL SERVER – Drop All the Foreign Key Constraint in Database – Create All the Foreign Key Constraint in Database
Need to drop all the foreign key constraints in a database and create them again? Here is a script by SQL expert Swastik Mishra that does both.
SQL SERVER – Listing Primary Key of Table with Stored Procedure sp_pkeys
Here is how to list the primary key of a table with the stored procedure sp_pkeys, a follow up to my earlier post on sp_fkeys.
SQL SERVER – Listing Foreign Key Relationships of Table with Stored Procedure sp_fkeys
A quick trick to list all the foreign key relationships of a table with the stored procedure sp_fkeys, with a sample script on AdventureWorks2012.
SQL SERVER – Create Unique Constraint on Table Column on Existing Table
Can you create unique constraint on a column of a table that already exists? Yes. Here is the short ALTER TABLE ADD CONSTRAINT script I use.
Soft Delete With an IsDeleted Column: Indexes, Views and Keys
Design soft delete with an IsDeleted flag, filtered unique keys and indexes, a live-row view, and a measured archive process.






