We have many DB's that are identical schema, but the FK names might not be. We do a lot of cloning for testing and such.
Ran into a problem with the clone when we added a self referencing Foreign Key. We can't go back and change all the older DB's, but just need a way to clone and skip past the constraint, and re apply at the end.
// Keeping the columns simplified to just the 2 main ones causing the issue.
Table [Employee]
Columns [EmpId(pk), ManagerId(fk)]
ManagerId --> EmpId
So, if the clone trys to insert the Employee wiht a managerId that does not exist, you get an FK error.
Found several ways to Alter(drop then add) or rename the FK, but i need to know at cone application run time the FK's name, so i can alter.
Please no lectures on cloning, or copying, or why we're doing things wrong. We did multi DB's this way and self referencing for internal reasons.