What is the difference between local temporary table and global temporary table?
There is no difference between local and global temporary tables.
local temporary tables are session specific and global temporary tables are common for all the sessions .
Local temporary tables are destroyed immediately after closing the client session. But Global temporary tables are destroyed when all the client sessions are destroyed.
Both second and third statements are correct.
Let us say an user connected to SQL Server using ado.net or by using any other technology, SQL Server creates a session. When the current user executes any stored procedure which is creating a local temporary table, it will be deleted when the corresponding users sessions is closed. But if the same user is calling any stored procedure which is creating a global temporary table, it will not be deleted immediately after deleting users sessions, but will be deleted only when all the client sessions are closed or when the SQL Server is restarted.
Back To Top