Temporary Tables in SQL Server

-> In SQL Server, temporary tables are created at run-time and you can do all the operations which you can do on a normal table. These tables are created inside Tempdb database. Based on the scope and behavior temporary tables are of two types

1) Local Temp Table (#)
2) Global Temp Table (##)

1) Local Temp Table
-> Local temp tables are only available to the SQL server session or connection that created that tables. There are automatically deleted when the session that created the tables has been closed. Local temporary table name is stored with single hash(#) sign

2) Global Temp Table
-> Global temp tables are available to all SQL server sessions or connetions (means to all users). These can be created by any SQL server connection user and these are automatically deleted  when all the SQL server connections have been closed.Global temporary table name is started with double hash (##) sign.

Leave a Reply

Your email address will not be published. Required fields are marked *