Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sql Query to find Temp tables in DB

Tags:

sql

sql-server

Please suggest me a query to find temp database tables.

like image 730
Simhadri Avatar asked Sep 15 '10 14:09

Simhadri


People also ask

How do I find temp tables in database?

Now, to see where this table exists; go to “Object Explorer -> Databases -> System Databases-> tempdb -> Temporary Tables”. You will see your temporary table name along with the identifier.

How do I find the temp table schema in SQL Server?

. Once the temp table has been created, execute this statement within the same session (tab in SSMS). The output will have a row per line definition of the table, in column order, that can be used to explicitly declare the temp table.


2 Answers

select name from tempdb.sys.tables
like image 187
Martin Smith Avatar answered Oct 02 '22 20:10

Martin Smith


All temp tables created are stored in the tempdb available on sql server. So run this query in tempdb, you will find available temp tables on the server -

select * from sysobjects where "xtype" = 'u'

Hope this will help you

like image 24
Sachin Shanbhag Avatar answered Oct 02 '22 20:10

Sachin Shanbhag