How to create a temporary table using the Create statement in SQL Server?

How to create a temporary table is similar to creating a normal table?

Example:

CREATE TABLE table_name 
(
    column1 datatype,
    column2 datatype,
    column3 datatype,
     ....
 );
+4
source share
2 answers

3 , #. , . @, . "" (, ..), . ## , #, , .

:

declare @table table (id int)
create table #table (id int)
create table ##table (id int)
select * into #table from xyz
+8

, # ##:

CREATE TABLE #TemporaryTable -- Local temporary table
(
    Col1 int,
    Col2 varchar(10)
    ....
);

CREATE TABLE ##GloablTemporaryTable -- Gloabl temporary table - note it starts with ##.
(
    Col1 int,
    Col2 varchar(10)
    ....
);

# ##. - , - .
- , .

+10

Source: https://habr.com/ru/post/1673223/


All Articles