Posted By

marcocs on 10/26/09


Tagged

sql admin


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

g8rpal
Tyster


Delete All Foreign Keys


 / Published in: SQL
 

Delete All Foreign Keys in a database; (make sure you USE keyword)

  1. SELECT 'ALTER TABLE ' + TABLE_SCHEMA + '.[' + TABLE_NAME
  2. + '] DROP CONSTRAINT [' + CONSTRAINT_NAME + ']'
  3. FROM information_schema.table_constraints
  4. WHERE CONSTRAINT_TYPE = 'FOREIGN KEY'

Report this snippet  

You need to login to post a comment.