Tuesday, May 7, 2013

Dropping all the temporary tables that are created in a seesion

Hi,


Try to list out all temp tables, like



select left(name, charindex('_',name)-1)
from tempdb..sysobjects
where charindex('_',name) > 0 and
xtype
= 'u' and not object_id('tempdb..'+name) is null


then use Dynamic sql to generate "Drop table" scripts.




Many Thanks & Best Regards, Hua Min


No comments:

Post a Comment