February 7, 2006 at 8:36 am
How I discover what the name of a temporary table associated with a SPID
TABLE #TEMP1
=
SELECT * tempdb..SYSOBJECTS[#TEMP1______________________________________________________________________________________________________________000000004078]
To do something like
IF EXISTS #TEMP1
DROP TABLE #TEMP1
Sergio
Sérgio C Fonseca
February 7, 2006 at 9:05 am
If you can use global temp tables...
IF EXISTS (SELECT 1 FROM TEMPDB..SYSOBJECTS WHERE NAME = '##xx' AND TYPE = 'U')
BEGIN
DROP TABLE ##xx
END
If you are using local temp tables, the name in Tempbdb..sysobjects will be tricky to find(you can use like to find it..but keep in mind that if the table name is common..you can multiple temp tables with similar name)
HTH
Mathew J Kulangara
sqladventures.blogspot.com
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply