Archive for the ‘SQL Server’ Category
SQL Script – Dropping Foreign Keys
I stumbled across the following script today which generates the SQL for dropping foreign keys:
SELECT 'ALTER TABLE ' + OBJECT_NAME(parent_object_id) +
' DROP CONSTRAINT ' + name FROM sys.foreign_keys
WHERE
referenced_object_id in (object_id('TableName1'), object_id('TableName2'),
object_id('TableName3'))