On Global Temp Tables

Denis Gobo riffs on global temp tables:

SQL Azure has added something called database scoped global temporary tables.

Azure SQL Database supports global temporary tables that are also stored in tempdb and scoped to the database level. This means that global temporary tables are shared for all users’ sessions within the same Azure SQL database. User sessions from other Azure SQL databases cannot access global temporary tables.

They way you add these is by using a double pound sign

Click through for more.  I will occasionally use a global temp table, mostly in conjunction with Central Management Server queries going over a set of databases on each instance, but I limit my usage to manual operations and nothing as part of a normal application or administrative process.

Related Posts

Constraints On Temp Tables

Kenneth Fisher argues that you should use default naming for temp table constraints: You should be able to create a #temp in every session. That’s the idea, right? It’s one of the things that differentiates a global temp table from a local temp table. But there can be some difficulties with that. If you are working with reusable […]

Read More

Checking For Temp Table Existence

Wayne Sheffield offers a clinic on temp tables: I was recently reviewing a newly created T-SQL stored procedure. This procedure was verifying temporary table existence with the following code: 2 IF exists (select * from tempdb..sysobjects where name like ‘#fg%’) DROP TABLE #fg Seeing this takes me back to one of my favorite presentations, where […]

Read More


August 2017
« Jul Sep »