Is there a way to get a list of all current temporary tables in SQL Server?
Is this what you are after?
select * from tempdb..sysobjects--for sql-server 2000 and later versionsselect * from tempdb.sys.objects--for sql-server 2005 and later versions
You can get list of temp tables by following query :
select left(name, charindex('_',name)-1) from tempdb..sysobjectswhere charindex('_',name) > 0 andxtype = 'u' and not object_id('tempdb..'+name) is null
SELECT left(NAME, charindex('_', NAME) - 1)FROM tempdb..sysobjectsWHERE NAME LIKE '#%' AND NAME NOT LIKE '##%' AND upper(xtype) = 'U' AND NOT object_id('tempdb..' + NAME) IS NULL
you can remove the ## line if you want to include global temp tables.