Microsoft SQL Temporary Tables
--There are two types of temporary tables
-- i Local Temporary tables exisit for the one session and start with a single hash sign # at begin of name
-- ii Global Temporary Tables exists for all sessions and start with two hash signs ## at begin the name
-- ii.2 Global Temporary Tables are only dropped once the last connection is terminated.
-- Local Tempoary Table 1
create table #testeri (i int, abc varchar(10));
insert into #testeri values (1,'erd'), (2,'dre'), (3,'plc'), (4,'qlc')
select * from #testeri;
-- Local Temporary Table2
select top 3 *
into #insertioni
from dbo.[options ftse];
select * from #insertioni;
-- Global Tempoary Table 1
create table ##testeriGlobal (i int, abc varchar(10));
insert into ##testeriGlobal values (1,'erd'), (2,'dre'), (3,'plc'), (4,'qlc')
select * from ##testeriGlobal;
-- Global Temporary Table2
select top 3 *
into ##insertioniGlobal
from dbo.[options ftse];
select * from ##insertioniGlobal;
------------------------------
--------------------
select * from #testeri;
select * from #insertioni;
select * from ##testeriGlobal;
select * from ##insertioniGlobal;
--There are two types of temporary tables
-- i Local Temporary tables exisit for the one session and start with a single hash sign # at begin of name
-- ii Global Temporary Tables exists for all sessions and start with two hash signs ## at begin the name
-- ii.2 Global Temporary Tables are only dropped once the last connection is terminated.
-- Local Tempoary Table 1
create table #testeri (i int, abc varchar(10));
insert into #testeri values (1,'erd'), (2,'dre'), (3,'plc'), (4,'qlc')
select * from #testeri;
-- Local Temporary Table2
select top 3 *
into #insertioni
from dbo.[options ftse];
select * from #insertioni;
-- Global Tempoary Table 1
create table ##testeriGlobal (i int, abc varchar(10));
insert into ##testeriGlobal values (1,'erd'), (2,'dre'), (3,'plc'), (4,'qlc')
select * from ##testeriGlobal;
-- Global Temporary Table2
select top 3 *
into ##insertioniGlobal
from dbo.[options ftse];
select * from ##insertioniGlobal;
------------------------------
select * from #testeri;
select * from #insertioni;
select * from ##testeriGlobal;
select * from ##insertioniGlobal;
No comments:
Post a Comment