I've been trying to find a way to delete some foreign keys generated by mistake, but each time I DROP the table associated with the foreign key to try and erase it, it says "cannot drop index: needed in foreign key constraint".
If you are getting an error Cannot drop index 'fk_role_id': needed in a foreign key constraint, it means you are trying to drop the index without dropping the foreign key. To drop the index you have to drop the foreign key first. After that, you can drop the index.
In "Structure" tab, click on "see relational view" below the fields. Here you can remove the foreign keys by selecting an empty value in the dropdown.
When a referenced foreign key is deleted or updated, respectively, the columns of all rows referencing that key will be set to NULL . The column must allow NULL or this update will fail.
To delete a foreign key constraint In Object Explorer, expand the table with the constraint and then expand Keys. Right-click the constraint and then click Delete.
In "Structure" tab, click on "see relational view" below the fields. Here you can remove the foreign keys by selecting an empty value in the dropdown.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With