Local temporary tables are removed at the end of the current session
1>
2>
3> CREATE TABLE project (project_no CHAR(4) NOT NULL,
4> project_name CHAR(15) NOT NULL,
5> budget FLOAT NULL)
6> GO
1> insert into project values ('p1', 'Search Engine', 120000.00)
2> insert into project values ('p2', 'Programming', 95000.00)
3> insert into project values ('p3', 'SQL', 186500.00)
4> GO
(1 rows affected)
(1 rows affected)
(1 rows affected)
1> select * from project
2> GO
project_no project_name budget
---------- --------------- ------------------------
p1 Search Engine 120000
p2 Programming 95000
p3 SQL 186500
(3 rows affected)
1>
2> -- Temporary Tables
3>
4> -- Local temporary tables are removed at the end of the current session.
5> -- They are specified with the prefix #
6>
7> -- Global temporary tables, which are specified with the prefix ##, are dropped at the end of the session that created this table.
8>
9>
10>
11> SELECT project_no, project_name
12> INTO #project_temp
13> FROM project
14> GO
(3 rows affected)
1>
2> select * from #project_temp
3> GO
project_no project_name
---------- ---------------
p1 Search Engine
p2 Programming
p3 SQL
(3 rows affected)
1>
2> drop table #project_temp
3> drop table project
4> GO
1>
Related examples in the same category