Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Query for finding out whether a temp table is used

Author  Topic 

phrankbooth
Posting Yak Master

162 Posts

Posted - 2013-09-11 : 12:38:48
I see many temp tables listed under temp db. I have reason to believe those are old and should not be there, but I'd like to know if indeed they are being used from some process or SP.

How would I query the system to get this information?

Thanks!!

--PhB

denis_the_thief
Aged Yak Warrior

596 Posts

Posted - 2013-09-12 : 15:00:12
I believe there is no way. The Temporary DB is just that. A Temporary Database - SQL Server uses it as it wishes. I think it leaves some tables hanging around as a sort of caching mechanism - if it needs to use that same table structure it already exists and it can save a little time rather than recreating it.

The tempdb is SQL Server's own thing and it uses it as it pleases in it's own internal way. I would just ignore those tables. If it needs to reclaim the space, it will delete them otherwise there is no urgency for it to delete these.

An analogy would be if you want to see which variables still exist during or after a stored procedure.
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2013-09-12 : 15:37:15
It depends whether they are ordinary temp tables , global temporary tables or ordinary tables. Each are treated differently and can be managed in different ways

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page
   

- Advertisement -