- Option 1 – sys. tables. The sys.
- Option 2 – sys. tables. You can also use the sys.
- Option 3 – INFORMATION_SCHEMA. TABLES.
- Option 4 – sp_tables. If you're looking for a stored procedure option, the sp_tables stored procedure will do the trick.
- Option 5 – dbo. sysobjects.
People also ask, how do I find temporary tables in SQL Server?
Temporary tables are stored in tempdb. They work like a regular table in that you can perform the operations select, insert and delete as for a regular table. If created inside a stored procedure they are destroyed upon completion of the stored procedure.
Also Know, how many temporary tables are there in SQL Server? There are 2 types of Temporary Tables: Local Temporary Table, and Global Temporary Table.
Besides, how would you get the list of all local and global temp tables in SQL Server?
Listing SQL Server Local and Global Temporary Tables
The set of all tables in tempdb can be obtained by referencing tempdb.sys.tables in the from clause of a select statement.
How do I know if a temp table exists?
Check If Temporary Table or Temp Table Exists in SQL Server
- create table TestTable(id int)
- create table #TestTable(id int)
- select * from tempdb.sys.tables where name like '#TestTable%'
- select object_id('tempdb..#TestTable','U')
- if object_id('tempdb..#TestTable','U') is not null.