We are delighted to announce the general availability of Database Scoped Global Temporary Tables for Azure SQL DB. Similar to global temporary tables for SQL Server (tables prefixed with ##table_name), global temporary tables for Azure SQL DB are stored in tempdb and follow the same semantics. However, rather than being shared across all databases on the server, they are scoped to a specific database and are shared among all users’ sessions within that same database. User sessions from other Azure SQL databases cannot access global temporary tables created as part of running sessions connected to a given database. Any user can create global temporary objects.
Example
- Session A creates a global temp table ##test in Azure SQL Database testdb1 and adds 1 row
T-SQL command
CREATE TABLE ##test ( a int, b int);
INSERT INTO ##test values (1,1);
- Session B connects to Azure SQL Database testdb1 and can access table ##test created by session A
SELECT * FROM ##test
---Results
1,1
For more information on Database Scoped Global Temporary Tables for Azure SQL DB see CREATE TABLE (Transact-SQL).