Head.SmackOnTable();

Contains Nuts.

Clearing FK’s and tables from database

without comments

SELECT 'ALTER TABLE ' +  OBJECT_NAME(f.parent_object_id) + ' DROP CONSTRAINT [' + f.name + ']' FROM sys.foreign_keys AS f INNER JOIN sys.foreign_key_columns AS fc ON f.OBJECT_ID = fc.constraint_object_id
union all
SELECT 'DROP TABLE '+ name FROM dbo.sysobjects WHERE (type = 'u') and name != 'sysdiagrams'
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • DotNetKicks
  • DZone

Written by Monty

July 14th, 2009 at 4:45 pm

Posted in Misc

Leave a Reply