Groups | Blog | Home
all groups > sql server programming > june 2004 >

sql server programming : DROPing foreign keys


Edgard Riba
6/11/2004 5:30:52 PM
Hi,
Is there an easy way to drop all foreign keys from a database?
Thanks,
Edgard L. Riba

Hari Prasad
6/12/2004 8:41:24 AM
Hi,

Execute the below command in Query Analyzer with Text result with the
database you need to drop all foreign key constraints.
Copy the result in to a new window and execute to drop all foreign keys.

select 'alter table '+TABLE_NAME +' drop constraint
'+CONSTRAINT_NAME+char(10)+'go' from information_schema.table_constraints
where constraint_type='Foreign key'

Thanks
Hari
MCDBA

[quoted text, click to view]

AddThis Social Bookmark Button