Dear SO :)
I have to merge data from one table to another. Both of these tables have the same structure, something like this:
Id (PK*) | Name | ParetnId (FK to PK*, it's a tree)
What I'm trying to use:
- Plain insert/update - too long SQL, FK/PK issues (when I copy row with ParentId to not existing row)
- merge operator - much shorter, but the same issues
I know that some guys temporary turn constraints off, copy data and turn constraints on again. In my case I trying to avoid this. (Many threads writing to these tables, and I don't know how such tricks affected to transactions)
The problem is: how to merge (or just copy) records between such tables without turning constraints off.