Temporary Tables

Learn how to create and use temporary tables.

Besides table variables, there are temporary tables we can utilize in our complex queries to hold intermediate data. Unlike table variables that exist only within the scope of a batch, temporary tables are accessible throughout the whole session when there’s a connection to the MS SQL Server. Temporary tables can be either local or global.

Temporary table types

There are two types of temporary tables in MS SQL Server.

Local temporary tables

Local temporary tables are accessible only from the session they are created in. Users or applications connected to the MS SQL Server are ...