Its back to back post today.The script I am sharing today is very useful and I actually
found it way back last year,so thought to share it.
–To get all foreign key relationships referencing your table, you could use this SQL (if you’re on SQL Server 2005 and up):
WHERE referenced_object_id = object_id(TableName)
–and if there are any, with this statement here, you could create SQL statements to actually drop those FK relations:
‘ALTER TABLE ‘ + OBJECT_NAME(parent_object_id) +
‘ DROP CONSTRAINT ‘ + name
WHERE referenced_object_id = object_id(‘Student’)
I would like to have feedback from my blog readers.
Please post your feedback, question, or comments about this article.