>>One more variation to try
>>
>>delete from myDataBase.OriginalClients OC
>>where exists (select 1 from ToRemove where ToRemove.ClientID = OC.CLientID)
>
>Same result. Just thinking, is there any way to selectively turn of RI code? I don't really need to worry about that in this scenario because the archive routine loops recursively through all table relationships anyway.
Not with native RI, unfortunately. If you use any other RI generator (from Doug Hennig or from Walter Meester, for example), then it's easy to turn it off/on on demand.
One more possibility would be to have
EnableTriggers() and _ri_delete() in the triggers for each of the table. Then EnableTriggers() function would return t. or .f. depending on your conditions and everything would work as is. But it means you do need to manually adjust all your tables one time. I'm also not 100% certain RI Builder keeps the information we already have in the trigger and just adds itself at the end.
If it's not broken, fix it until it is.
My Blog