Home > DeveloperSection > Forums > How to create local temporary table in Sqlserver.
Ankit Singh

Total Post:341

Posted on    October-30-2015 2:17 AM

 .NET SQL Server 

 1 Reply(s)
 531  View(s)
Rate this:
Can anyone please help me how to solve this problem.

aditya kumar Patel

Total Post:254

Posted on    October-30-2015 2:37 AM

SQL Server provides the concept of temporary table which helps the developer in a best way. These tables can be created at runtime and can do the all kinds of operations that one normal table can do. But, based on the table types, the scope is limited. These tables are created inside tempdb database. Local temp tables are only available to the current connection for the user; and they are automatically deleted when the user disconnects from instances. Local temporary table name is stared with hash ("#") sign.

--step 1 create local temporary table



OrderID int,

Orderdate datetime,

amount decimal(10,2)


--step-2 insert data in #temptabl from order table

insert into #temptbl select * from [Order]

--step-3 select data from #temptabl

select * from #temptbl

Modified On Oct-30-2015 03:02:32 AM

Don't want to miss updates? Please click the below button!

Follow MindStick