twoeyed (10/26/2012)
Thank you all for taking the time to reply and for your valuable inputs.I have managed to reduce the execution to around 6 minutes through the ideas proposed, which is not bad at all.
Thank you Chris and David for the posting advice.
Hi
It's good practice to post your final solution - it provides useful feedback to those who may have helped you, may help others who stumble upon this thread, and in some cases encourages another round of improvement.
Cheers.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden