Temporary table is very useful feature to store temporary data in a database. These tables are saved in “Tempdb” database.
Temporary tables are used with keyword “#” and "##".
There are two types of temporary tables in a database which are following:
1. Local Temporary table :
These tables will remain in a database until users connect with Server. It will delete when connection is closed. It starts with “#” as prefix of table name.
Syntax :
CREATE Table #Table_Name(Column1 datatype, Column2 datatype….)
Example :
Suppose you want to store data for temporary purpose, you can create temporary tables by using # keywords.
The following query is used to create Temporary Table “#EmployeeData” .
CREATE TABLE #EmployeeData
(Id int,
Name varchar(10),
DeprtmentName Varchar(10))
Now inserted some values in above created table.
insert into #EmployeeData values (1,'Anny','IT')
insert into #EmployeeData values (2,'Jonathan','SALES')
insert into #EmployeeData values (3,'Lester','Finance')
Now You can fetch records from “#EmployeeData” table by using below query.
select * from #EmployeeData
Output:
2 Global Temporary table :
These tables will delete when all connections are closed. It starts with “##” as prefix of table name.
Syntax :
CREATE Table ##Table_Name(Column1 datatype, Column2 datatype….)
Example :
Also You can create global temporary tables by using ## keywords.The following query is used to create Temporary Table “##Customer” .
CREATE TABLE ##Customer
(Id int,
Name varchar(10),
Contactno Numeric(18,0))
Now inserted some values in above created table.
insert into ##Customer values (1,'Nancy','9997483450')
insert into ##Customer values (2,'Mohan','9897473456')
insert into ##Customer values (3,'Mhesh','8997493401')
Now You can fetch records from “##Customer” table by using below query.
select * from ##Customer
Output:
If you want to sell your readymade software to the genuine clients or businessman, list your software with details and demo links.
Clients will find it using our advanced search filter and will contact you directly.
No any charge for the product lsiting.