• I think this is a good example of why you (the OP) should provide full disclosure when asking a question. Eugene's first answer is a good one based limited information. Had we been able to see the actual stored procedure a better answer could have been given up front.

    Who knows, we may have even seen a way to improve it overall.