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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Query for finding out whether a temp table is used
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

162 Posts

Posted - 09/11/2013 :  12:38:48  Show Profile  Reply with Quote
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?



Aged Yak Warrior

596 Posts

Posted - 09/12/2013 :  15:00:12  Show Profile  Reply with Quote
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

Flowing Fount of Yak Knowledge

United Kingdom
2179 Posts

Posted - 09/12/2013 :  15:37:15  Show Profile  Visit jackv's Homepage  Reply with Quote
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000