Nice work solving it by disabling constraints and triggers — I’ve dealt with similar FK-related copy issues before and know how frustrating it can get.
Just to add another option for similar situations:
I’ve built a tool for SQL Server that copies related data between tables within the same database — keeping foreign key relationships intact and remapping identity values where needed.
It’s useful when:
- You need to duplicate rows across related tables (e.g. copy an order with its items and comments)
- Foreign keys must be preserved correctly
- The insert order must follow dependency rules automatically
- You want to apply filters or dry-run first
- You prefer not to disable constraints or write custom scripts
It doesn’t handle cross-database migration, but for deep-copy scenarios inside one database, it can save a lot of time.
If anyone’s interested in testing it or giving feedback, I’d be happy to share it privately.