Please enable JavaScript.
Coggle requires JavaScript to display documents.
SQL Temp table - Coggle Diagram
SQL Temp table
Local Temporary Tables
The Local temp tables are only available to the current connection for the user, and they are automatically deleted when the user disconnects from instances. The local temporary table name is stared with hash (“#”) sign.
CREATE TABLE #PersonDetails(Id Int, Name Varchar(50))
Local table name must not be unique. SQL Server appends some random numbers at the end of the local temp table name
Local temporary tables are automatically dropped; when the session that created, the temporary tables are closed.
Global Temporary Tables
Global Temporary tables name starts with a double hash (“##”). Once this table has been created by a connection, like a permanent table it is then available to any user by any connection. It can only be deleted once all connections have been closed.
CREATE TABLE ##PersonDetails(Id Int, Name Varchar(50))
Global temporary tables are also automatically dropped when the session that creates the temporary tables is closed.
When to use
Loading data into a temporary table speeds up the process because all the operations are performed locally on the client.
Use of the Temporary Tables reduces the load on both the network and server as all the interaction with temporary tables occurs on the Client.
-
-