Home > DeveloperSection > Interviews > What is the differences between local and global temporary tables in sql server?

Posted on    February-26-2016 11:00 PM

 MSSQL Server Database  SQL  SQL Server 2008  SQL Server 2012  Database Design  Database Table 
 1 Answer(s)
  601  View(s)
Rate this:

Anupam Mishra

Total Post:23

Posted on    February-27-2016 12:00 AM

Global Temp Variable:
Global temp tables name starts with double hash (##) in sql server. Once this table is created in database, it is like a permanent table in tempdb->temporary tables. It is always ready for all users and not deleted until the total connection is withdrawn.

CREATE TABLE ##StudentTemp
Username varchar(50),  
User_address varchar(150)
Local Temp Variable:
Local temp tables are only available at current connection time in sql server database. It is automatically deleted when user disconnects from instances. It is started with hash (#) sign.

Username varchar(50),  
User_address varchar(150)

Don't want to miss updates? Please click the below button!

Follow MindStick