HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlModerate

How to get a list of global temporary tables in the current database?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
globaltablesthetemporarydatabasegetcurrenthowlist

Problem

I am trying to get a list of the global temporary tables that are currently active. There seems to be an issue with them bumping in to each other (same name). As the 'acting' dba, trying to sort out a mess here.

Solution

For SQL Server 2005+, all global temp tables (tables that are created with a ## prefix) will be found in tempdb. This should work for you:

SELECT * FROM tempdb.sys.tables
WHERE name LIKE '##%'

Code Snippets

SELECT * FROM tempdb.sys.tables
WHERE name LIKE '##%'

Context

StackExchange Database Administrators Q#33685, answer score: 12

Revisions (0)

No revisions yet.