• Thanks so much. Basically you guessed all. And I tried your code; rewrite mine according to your suggestions. Now it works very well without the tempdb problem after a couple of tests. You did save me! Additionally yours is much more readable and easier to reuse. All my best to you!!