Groups | Blog | Home
all groups > sql server programming > august 2003 >

sql server programming : Drop temp tables in tempdb


Hassan
8/16/2003 10:19:50 PM
I see some temp tables in tempdb such as
#tablename_________________________X23 as an example when i query
tempdb..sysobjects. I noticed the create date of last month . I tried to do
a select * from that table and it says invalid object. So how come I see it
there ? Also how can i drop it . I am using SQL 2000.

Jason W. Paul
8/17/2003 4:43:53 AM
May not be the best way, but if you stop the SQL service
and restart it, then tempdb will be rebuilt and all of the old
cruft will disappear.


[quoted text, click to view]

Random
8/17/2003 6:44:08 AM
Try surrounding your table name with brackets. eg:
select * from [#tablename________________________X23]


On Sun, 17 Aug 2003 04:43:53 -0400, "Jason W. Paul"
[quoted text, click to view]
Erland Sommarskog
8/17/2003 7:57:02 PM
[posted and mailed, please reply in news]

Hassan (fatima_ja@hotmail.com) writes:
[quoted text, click to view]

These tables are temp tables created by some process that lags around.
The way to get rid of the tables is to kill the process. One way to
find this process is to do:

SELECT * FROM master..sysprocess WHERE login_time < @crdate

where @crdate is the creation-data for the temp table. But before you
kill any process, check that it is not doing anything useful.

Restarting SQL Server as suggested in another posting is a more
definitive way to get rid of them.
--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
AddThis Social Bookmark Button