Difference between a Local and a Global temporary table

What is the difference between a Local and a Global temporary table?

Temporary tables are used to allow short term use of data in SQL Server. They are of 2 types:

Local
- Only available to the current Db connection for current user and are cleared when connection is closed.
- Multiple users can’t share a local temporary table.

Global
- Available to any connection once created. They are cleared when the last connection is closed.
- Can be shared by multiple user sessions.

What is the difference between a Local and a Global temporary table?

A local temporary table lives until the connection is valid or until the duration of a compound statement.

A global temporary table is permanently present in the database. However, the rows of the table are present until the connection is existent. Once the connection is closed, the data in the global temporary table disappears. However, the table definition remains with the database for access when database is opened next time.
SQL Server - What is the STUFF and how does it differ from the REPLACE function?
What is the difference between UNION and UNION ALL? - .....
Rules to use ROWGUIDCOL property to define globally unique identifier column
A table can have only one ROWGUIDCOL column, A ROWGUIDCOL column must be defined by using the uniqueidentifier data type.......
Actions prevented once referential integrity is enforced
Following are the actions prevented once referential integrity is enforced.......
Post your comment
Discussion Board
Temporary Table.
Hi Rajmeet Ghai,

If you Dont know the exact answer then please dont share your wrong concept with others.your global temporary table concept is entirely wrong..

Dont Mind Please.
Santosh S Pawar 03-16-2012