SELECT <columns> INTO #TempTableA FROM <files and joins> SELECT <columns> INTO #TempTableB FROM <files and joins> SELECT <columns> FROM #TempTableA, #TempTableB <where whatever> DROP TABLE #TemptableA DROP TABLE #TempTableBThe #TemptableA will create a temp table that's unique to the connection. And then you drop them at the end.