Post by Andy Dufresne
but what happens to that #temp table after I'm done with the query? Does
it stay in the database indefinately until it's manually removed? Do I
have to do something to clean it up?
A temp table is dropped when you exit the scope it was create in. If you
create it from the top-level scope, for instance directly in a query window,
the table is dropped when you disconnect.
Note that the temp table does not exist in your database, but in tempdb.
Erland Sommarskog, SQL Server MVP, ***@sommarskog.se
Books Online for SQL Server 2005 at
Books Online for SQL Server 2000 at