When you use SQL Server, what is a difference between local and global temporary table?
Experience Level: Senior
Tags: DatabasesMS SQL ServerSQL
Answer
Explanation
There are two types of temporary tables: local and global.
Local temporary tables (#table)
- Local temporary tables are visible only to their creators during the same connection to an instance of SQL Server as when the tables were first created or referenced.
- Local temporary tables are deleted after the user disconnects from the instance of SQL Server.
Global temporary tables (##table)
- Global temporary tables are visible to any user and any connection after they are created, and are deleted when all users that are referencing the table disconnect from the instance of SQL Server.
Related Databases job interview questions
What is the difference between UNION and UNION ALL?
DatabasesSQL MediorWhat is the processing order of logical parts of the following query?
DatabasesSQL MediorWhat is a result of the query below for table with 10 rows when there are 2 clients with the headcount column having a NULL value, there are 7 customers with 1 head and 1 customer with 2 heads?
DatabasesSQL MediorWhat is a result of the following query for table with 10 rows when there are 2 clients with the name column having a NULL value?
DatabasesSQL Medior