Using 2 temp tables in a query
It shouldn't cause any speed problems unless it is called
many times concurrently - in which case you can get
contention with tempdb system tables.
Look at the query plan to see how the SP is optimised.
Sounds like the optimiser may be making a mistake.
Make sure statistics are up to date.
If you only have one row in one of the temp tables you
could use variables instead.
query
has
|