I realize that temporary tables are session/connection bound and not visible or accessible out of the session/connection.
I have a long running stored procedure that creates temporary tables at various stages.
Is there a way I can see the list of current temporary tables? What privileges do I need to be able to do so?
Alternatively,
Is there a way I can see the particular SQL statement being executed inside a running stored procedure? The procedure is running as a scheduled job in SQL Server.
I am using SQL Server 2000.
Thanks for your guidance.
SQL Server provides two types of temporary tables according to their scope: Local Temporary Table. Global Temporary Table.
There are 2 types of Temporary Tables: Local Temporary Table, and Global Temporary Table.
Is this what you are after?
select * from tempdb..sysobjects --for sql-server 2000 and later versions select * 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..sysobjects where charindex('_',name) > 0 and xtype = 'u' and not object_id('tempdb..'+name) is null
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With