Search code examples
sql-servertemp-tablesglobal-temp-tables

Local and global temporary tables in SQL Server


What is the difference between local and global temporary tables in SQL Server?


Solution

  • I find this explanation quite clear (it's pure copy from Technet):

    There are two types of temporary tables: local and global. Local temporary tables are visible only to their creators during the same connection to an instance of SQL Server as when the tables were first created or referenced. Local temporary tables are deleted after the user disconnects from the instance of SQL Server. Global temporary tables are visible to any user and any connection after they are created, and are deleted when all users that are referencing the table disconnect from the instance of SQL Server.