SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

phrankbooth
Posting Yak Master

USA
153 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?

Thanks!!

--PhB

denis_the_thief
Aged Yak Warrior

Canada
581 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

jackv
Flowing Fount of Yak Knowledge

United Kingdom
1911 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
--------------------
http://www.sqlserver-dba.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.05 seconds. Powered By: Snitz Forums 2000