How many types of Temporary Tables.
ajeet verma
Select an image from your device to upload
There are 2 types of temporary tables Local temporary table and global temporary table.
Local temporary tables are available in same query window where you create that table , outside of that window you can not access that table.
Syntax is very similar to create table just we need to add prefix # with table name like
Syntax :Create table #myTable
Local table are stored inside TempDB database. when we create Local temporary table sql server will add unique id automatically to that table in the end because there may be possibility to create same table with the same name from the other query window so for to make differentiate sql will add that unique key.
Scope of this table is local.
This table will be deleted when we close the query window from where we generate that table.
Global Temporary TableGlobal temporary table is work same as local temporary table difference is that the name of the Global temporary table is unique.Scope of this table is global means everyone can use this table who are not generate this table.
This table will dropped when all the connected users are disconnected from the sql server instance.
Syntax : Syntax is little bit different than local temporary table . we just need to add double ## sign prefix of the table name.
Create table ##myTable