• Also, no one is really going to dive into what you recently posted in an effort to help you figure out what be going on. We really need the information posted as DDL scripts, plus you should put together some sample data (i.e. NOT REAL data) for the tables that is representative of the problem. One other thing would really help, the actual execution plan.

    Also, do you really drop the temporary table as soon as it is populated as it appears in the code you posted?