What is the difference between Local Temp Table and Global Temp Table ?
Temporary tables are temporary storage structures.
You may use temporary tables to store data that you
will manipulate before arriving at a final format.
Temporary tables are temporary storage structures.
You may use temporary tables to store data that you
will manipulate before arriving at a final format.
Local Temp Table:
The hash (#) character (prefix with tablename) is used to declare a temporary table
as it is prepended to the table name. A single hash (#) specifies a local temporary table.
Local temporary tables are available to the current connection for the user, so they
disappear when the user disconnects. Within SQL Server, temporary tables are stored
in the Temporary Tables folder of the tempdb database.
as it is prepended to the table name. A single hash (#) specifies a local temporary table.
Local temporary tables are available to the current connection for the user, so they
disappear when the user disconnects. Within SQL Server, temporary tables are stored
in the Temporary Tables folder of the tempdb database.
Syntax for creating Local Temp Table
Create table #tempLocalTableName(EmpId int, EmpName varchar(50), EmpAdd varchar(100))
Global Temp Table:
Global temporary tables may be created with double hashes (##) (Prefix with table name).
These are available to all users via all connections, and they are deleted only when all
connections are closed. Once created, these tables are used just like permanent tables;
they should be deleted when you are finished with them.
These are available to all users via all connections, and they are deleted only when all
connections are closed. Once created, these tables are used just like permanent tables;
they should be deleted when you are finished with them.
Syntax for creating Temp Table
Create table ##tempGlobalTableName(EmpId int, EmpName varchar(50), EmpAdd varchar(100))
If you like this post share it.. If you encounter any problems, feel free and
comment below to find solution. Share Your Experience with us.