Delete All Foreign Keys


/ Published in: SQL
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.