SQL Server: Temporary Table

 SQL Server     sbo     Updated on Oct 17, 2013     VIKRAM     557   

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.

  Related Articles
Java Script: Create/Insert rows dynamically to HTML Table and Remove/Delete rows from HTML Table
Java Script: Create HTML Table dynamically
SQL Server: Delete record from parent table when there is Foreign Key relation between parent and child tables
SQL Server: NOT NULL Constraint
SQL Server: How to rename a column and How to rename a table
SQL Server: How to add a column to table and How to delete a column from table
ASP.Net: ListView Basics - ItemDeleting
SQL Server: How to create a table
  Recent Articles
Java Script: Create/Insert rows dynamically to HTML Table and Remove/Delete rows from HTML Table
Java Script: Create HTML Table dynamically
SQL Server: Delete record from parent table when there is Foreign Key relation between parent and child tables
SQL Server: NOT NULL Constraint
SQL Server: How to rename a column and How to rename a table
SQL Server: How to add a column to table and How to delete a column from table
ASP.Net: ListView Basics - ItemDeleting
SQL Server: How to create a table