What is Temporary Table in SQL Server?
Introduction:
In this article i will explain what is Temporary Table in SQL Server.
Description:
In previous articles i explained few sql commands. Now i will explain what is Temporary Table in SQL Server.
Temporary Table is created in tempdb database. Prefix "#" to create temporary table.
Syntax:
Create table #<table-name> ( <column-name> <data-type>, .. )
Following figure shows the list of Temporary Tables present in tempdb before creating the temporary table.
Example:
Create table #Emp
(
EmpNo int identity(1,1),
EmpName varchar(20)
)
Following figure shows the list of Temporary Tables present in tempdb after creating the temporary table.
Note:
After restarting the SQL Server, the temporary table is deleted from tempdb database.
-
CreatedOct 17, 2013
-
UpdatedOct 03, 2020
-
Views1,911
Related Articles
Different types of variables in SQL Server
What is Cross Join in SQL Server
How delete record from parent table when there is Foreign Key relation in SQL Server
What is the differences between CHAR, NCHAR, VARCHAR and NVARCHAR in SQL Server?
How to add or remove a column from a table in SQL Server?
How to insert values into Identity Column in SQL Server?
How to get a fixed-length value in SQL Server?
What is Left Join (or) Left Outer Join in SQL Server?
How to get current week dates in SQL Server?
What are the different types of Date formats in SQL Server?