sql server drop all tables foreign keys
sql server drop all tables foreign keys
SELECT 'ALTER TABLE ' + OBJECT_NAME(parent_object_id) AS TableName ,
'DROP CONSTRAINT '+ OBJECT_NAME(OBJECT_ID) AS NameofConstraint
FROM sys.objects
WHERE type_desc LIKE 'FOREIGN_KEY_CONSTRAINT'--'%CONSTRAINT'
GO
TableName NameofConstraint
ALTER TABLE profile DROP CONSTRAINT FK_User_UserId
ALTER TABLE UserAddress DROP CONSTRAINT FK_UserAddress_UserId
ALTER TABLE UserContact DROP CONSTRAINT FK_UserContact_UserId
No comments:
Post a Comment