sql temporary table in stored procedure

Relational Database Management System support temporary tables. Sql Temporary Tables are a serious feature that lets you reserve and process intermediate outcome by using the same selection, update, and join ability that you can use with traditional SQL Server tables.

The SQL temporary tables could be very helpful in some cases to stay temporary data. The greatest important thing that should be known about SQL temporary tables is that they will be dropped when the current client session finish.

Temporary tables are obtained in MySQL version 3.23 onwards. In older version of MySQL 3.23, you can’t play with temporary tables.

As stated earlier, SQL temporary tables will only remain as long as the current session is alive. If you run the code in a Java script, the temporary table will be crash automatically when the script complete executing. If you are connected to the MSSQL database server through the MSSQL management studio, then the SQL temporary table will remain until you close the client or manually delete the table.


Types of Temporary Tables

SQL Server contribute two types of SQL temporary tables based on the working and range of the table.

  • Global Temp Table
  • Local Temp Table


Global Temp Table

Global SQL Temporary tables name prefix with a double hash (“##”). Once global temp table has been generated by a connection, its work like a permanent table it is available to all user by any connection. It can only be remove once all connections have been closed.


Local Temp Table

Local temp tables are only available to the current user for the current connection; and they are automatically dropped when the user disconnects. Local temporary table name prefix  with single hash (“#”) sign.


Leave a Comment